Uncaught TypeError: node.parentNode is null
See original GitHub issueDescribe the bug
When running the following code:
{#if item.assignedTo === item.postToGroupId}
<div class="inline-block">
<Dropdown bind:value={item.assignedTo} dropdownOptions={assignedToOptions} label="Assigned To"
extraSmall="true" small="true" hideValues={true} on:update={() => handleAssignChange(item)} />
</div>
{:else}
{#each filterOptions as person}
{#if person.value.assignedTo === item.assignedTo}
{person.title}
{/if}
{/each}
{/if}
Where when the drop down is selected it changes the if value.
Reproduction
{#if item.assignedTo === item.postToGroupId}
<div class="inline-block">
<Dropdown bind:value={item.assignedTo} dropdownOptions={assignedToOptions} label="Assigned To"
extraSmall="true" small="true" hideValues={true} on:update={() => handleAssignChange(item)} />
</div>
{:else}
{#each filterOptions as person}
{#if person.value.assignedTo === item.assignedTo}
{person.title}
{/if}
{/each}
{/if}
running something like above reproduces it. A if statement that has a sub component that changes the if.
Logs
Uncaught TypeError: node.parentNode is null
detach index.mjs:373
add_resize_listener index.mjs:720
destroy Dropdown.svelte:1278
transition_out index.mjs:1123
run index.mjs:18
run_all index.mjs:24
go index.mjs:1321
run_tasks index.mjs:175
run_tasks index.mjs:174
raf index.mjs:163
run_tasks index.mjs:181
raf index.mjs:163
run_tasks index.mjs:181
raf index.mjs:163
run_tasks index.mjs:181
raf index.mjs:163
run_tasks index.mjs:181
raf index.mjs:163
run_tasks index.mjs:181
raf index.mjs:163
run_tasks index.mjs:181
raf index.mjs:163
run_tasks index.mjs:181
raf index.mjs:163
run_tasks index.mjs:181
raf index.mjs:163
run_tasks index.mjs:181
raf index.mjs:163
loop index.mjs:196
go index.mjs:1298
run index.mjs:1346
outro Dropdown.svelte:1271
transition_out index.mjs:1127
update Dropdown.svelte:397
update Dropdown.svelte:2264
update index.mjs:1075
flush index.mjs:1042
promise callback*schedule_update index.mjs:1000
make_dirty index.mjs:1777
ctx index.mjs:1815
setItem Dropdown.svelte:2359
click_handler_1 Dropdown.svelte:203
click_handler_1 Dropdown.svelte:1500
listen index.mjs:412
listen_dev index.mjs:1961
mount Dropdown.svelte:1555
mount Dropdown.svelte:1450
mount Dropdown.svelte:1392
mount Dropdown.svelte:2091
mount Dropdown.svelte:1194
update Dropdown.svelte:392
update Dropdown.svelte:2264
update index.mjs:1075
index.mjs:373:4
detach index.mjs:373
add_resize_listener index.mjs:720
destroy Dropdown.svelte:1278
transition_out index.mjs:1123
run index.mjs:18
forEach self-hosted:208
run_all index.mjs:24
go index.mjs:1321
run_tasks index.mjs:175
forEach self-hosted:4339
run_tasks index.mjs:174
(Async: FrameRequestCallback)
raf index.mjs:163
run_tasks index.mjs:181
(Async: FrameRequestCallback)
raf index.mjs:163
run_tasks index.mjs:181
(Async: FrameRequestCallback)
raf index.mjs:163
run_tasks index.mjs:181
(Async: FrameRequestCallback)
raf index.mjs:163
run_tasks index.mjs:181
(Async: FrameRequestCallback)
raf index.mjs:163
run_tasks index.mjs:181
(Async: FrameRequestCallback)
raf index.mjs:163
run_tasks index.mjs:181
(Async: FrameRequestCallback)
raf index.mjs:163
run_tasks index.mjs:181
(Async: FrameRequestCallback)
raf index.mjs:163
run_tasks index.mjs:181
(Async: FrameRequestCallback)
raf index.mjs:163
run_tasks index.mjs:181
(Async: FrameRequestCallback)
raf index.mjs:163
loop index.mjs:196
go index.mjs:1298
run index.mjs:1346
outro Dropdown.svelte:1271
transition_out index.mjs:1127
update Dropdown.svelte:397
update Dropdown.svelte:2264
update index.mjs:1075
flush index.mjs:1042
(Async: promise callback)
schedule_update index.mjs:1000
make_dirty index.mjs:1777
ctx index.mjs:1815
setItem Dropdown.svelte:2359
click_handler_1 Dropdown.svelte:203
click_handler_1 Dropdown.svelte:1500
(Async: EventListener.handleEvent)
listen index.mjs:412
listen_dev index.mjs:1961
mount Dropdown.svelte:1555
mount Dropdown.svelte:1450
mount Dropdown.svelte:1392
mount Dropdown.svelte:2091
mount Dropdown.svelte:1194
update Dropdown.svelte:392
update Dropdown.svelte:2264
update index.mjs:1075
System Info
System:
OS: macOS 12.1
CPU: (8) x64 Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz
Memory: 1.34 GB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.13.1 - /usr/local/Cellar/node@16/16.13.1/bin/node
Yarn: 1.22.17 - /usr/local/bin/yarn
npm: 8.1.2 - /usr/local/Cellar/node@16/16.13.1/bin/npm
Browsers:
Brave Browser: 95.1.31.91
Chrome: 96.0.4664.110
Firefox: 95.0
Safari: 15.2
npmPackages:
@sveltejs/kit: ^1.0.0-next.196 => 1.0.0-next.202
svelte: ^3.44.2 => 3.44.3
Severity
annoyance
Additional Information
Only causes a console error, everything else works as expected.
Maybe something that just checks for null in this?
function detach(node) {
node.parentNode.removeChild(node);
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Javascript error: Cannot read property 'parentNode' of null
You are executing this code while the DOM is not ready. To prevent this, execute the code just before the </body> closing tag,...
Read more >TypeError: Cannot read property 'parentNode' of Null in JS
The "Cannot read property 'parentNode' of null" error occurs when you access the parentNode property on a null value. To solve the error,...
Read more >Uncaught TypeError: node.parentNode is null #7020 - GitHub
Describe the bug See: sveltejs/kit#3056 Reproduction Can't save my REPL right now due to: sveltejs/sites#189 Logs No response System Info ...
Read more >can't access property "parentNode", node is null - Laracasts
Uncaught (in promise) TypeError: can't access property "parentNode", node is null. Any insight why I get the following error when I try to...
Read more >Node.removeChild() - Web APIs - MDN Web Docs
The removeChild() method of the Node interface removes a child node from the DOM and returns the removed node.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I can’t save to the REPL either; I’ll open a bug about it in the appropriate repo, because it looks like a REPL bug that should be pretty easy to fix once reported.
Can you reproduce this in the Svelte REPL? If so, this probably belongs as an issue in the Svelte repo rather than here. If this only happens in Svelte-Kit, then please post a link to a Git repo that we can clone to reproduce the problem, as requested by the bug-reporting instructions. Thanks!