question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: d.firstChild is null

See original GitHub issue

I 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:closed
  • Created 5 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
lawrence-dolcommented, Sep 27, 2018

please test it out in your app before i cut a new release.

It works just fine. I measure a 6% performance improvement in Firefox (over 921 redraws).

/* File 7: domvm.micro.min.js */
// https://github.com/domvm/domvm (3.x-dev, micro build)
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(...
0reactions
leeoniyacommented, Sep 27, 2018

i added body stringification except for null, Array and List 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found