TypeError: d.firstChild is null
See original GitHub issueI am working on a problem that seems to be introduced by a relatively new build of DOMVM, meaning the code used to work without issue. The symptom is the type error in the subject.
I have not gotten to the point of a fiddle yet since I have no clue yet how to replicate the fault outside of the context of my app. All I am looking for at this point is suggestions for the kind of mistake or fault I could make that could cause the firstChild property to be unexpectedly null when patching.
If it helps, it seems to only happen when the display is recreated, but unchanged.
It happens in patch, here:
else {
// "" | null => []
if (newIsArr) {
clearChildren(donor);
hydrateBody(vnode);
}
// "" | null => "" | null
else if (nbody !== obody) {
if (nbody != null && obody != null)
{ el.firstChild.nodeValue = nbody; } // <== el.firstChild is null
else
{ el.textContent = nbody; }
}
}
The stacktrace is:
TypeError: el.firstChild is null, can't access property "nodeValue" of it[Learn More] AppScript:1498:8
patch https://localhost/jse/AppScript:1498:8
patchChildren https://localhost/jse/AppScript:1605:7
patch https://localhost/jse/AppScript:1480:7
patchChildren https://localhost/jse/AppScript:1605:7
patch https://localhost/jse/AppScript:1480:7
patchChildren https://localhost/jse/AppScript:1605:7
patch https://localhost/jse/AppScript:1480:7
patchChildren https://localhost/jse/AppScript:1605:7
patch https://localhost/jse/AppScript:1480:7
patchChildren https://localhost/jse/AppScript:1605:7
patch https://localhost/jse/AppScript:1480:7
patchChildren https://localhost/jse/AppScript:1605:7
patch https://localhost/jse/AppScript:1480:7
patchChildren https://localhost/jse/AppScript:1605:7
patch https://localhost/jse/AppScript:1480:7
patchChildren https://localhost/jse/AppScript:1605:7
patch https://localhost/jse/AppScript:1480:7
redrawSync https://localhost/jse/AppScript:1916:8
updateSync https://localhost/jse/AppScript:1942:10
patchChildren https://localhost/jse/AppScript:1612:7
patch https://localhost/jse/AppScript:1480:7
redrawSync https://localhost/jse/AppScript:1916:8
redraw https://localhost/jse/AppScript:1755:8
redraw/vm._redrawAsync< https://localhost/jse/AppScript:1757:73
call https://localhost/jse/AppScript:293:4
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
TypeError: Cannot read property 'firstChild' of Null in JS
The "Cannot read property 'firstChild' of null" error occurs when trying to access the firstChild property on a null value. Variables that store...
Read more >Uncaught TypeError: Cannot read property 'firstChild' of null
This part of the string: document.getElementById(\"artistID\"). Is looking for an ID of "artistID" . I assume you meant to concatenate the ...
Read more >Cannot read property 'firstChild' of null after upgrading to ...
If commentReplyTitleId does not exist, r will be null , hence different than undefined , so it tries to get the firstChild ....
Read more >Cannot read property 'firstChild' of null [solved] #44 - GitHub
I tested the last code I recommended with NW.js 0.17.1 32bit, and something very strange is happening.. I still get: Uncaught TypeError: Cannot ......
Read more >TypeError: this.obj.firstChild is null - Suite 5.0 - DHTMLX Forum
There is a error when I test. The code is: var w1 = createWindow("*^0^0^900^430^"+title, "<html></html>"); var toolbar = w1.
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 FreeTop 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
Top GitHub Comments
It works just fine. I measure a 6% performance improvement in Firefox (over 921 redraws).
i added
body
stringification except fornull
,Array
andList
types. all tests still pass. there was no measurable perf impact (in Chrome).please test it out in your app before i cut a new release.