Cannot read property 'insertBefore' of null
See original GitHub issueLooks like this is occurring in the createNewHosts function call.
function createNewHosts(cmps) {
var components = cmps.map(function (componentNode) {
var newNode = document.createElement(componentNode.tagName);
// display none
var currentDisplay = newNode.style.display;
newNode.style.display = 'none';
var parentNode = componentNode.parentNode;
parentNode.insertBefore(newNode, componentNode); //Problem hits here
//Potential fix simple but could avoid this in future.
if ( !!componentNode.parentNode ) {
var parentNode = componentNode.parentNode;
parentNode.insertBefore(newNode, componentNode);
}
return { currentDisplay: currentDisplay, newNode: newNode };
});
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
TypeError: Cannot read property 'insertBefore' of null
I happened to get the error just like you, and I guess the error might be Cannot read property 'insertBefore' of null ....
Read more >"TypeError: Cannot read property 'insertBefore' of null" #16
I'm still getting the `` error with the latest version of this. I did notice most of the other instances of this error...
Read more >Uncaught TypeError: Cannot read property 'insertBefore' of ...
However, it doesn't work and I get this error in the console every time: “Uncaught TypeError: Cannot read property 'insertBefore' of null”.
Read more >Error on Cannot read properties of null (reading insertBefore)
Hi Man. Which browser are you using? We found that some Chrome extensions are interfering with the Mendix client and cause this error....
Read more >Cannot read property 'insertBefore' of null at app.js:13 (Example)
Uncaught TypeError : Cannot read property 'insertBefore' of null at app.js:13 ... This is driving me insane, can't for the life figure out...
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 got same problem. Any update for this issue ?
The problem seems to be here in Helpers.js
var parentNode = componentNode.parentNode; <<< componentNode is “app-component” selector, parentNode is “NULL”… however… parent node in DOM is <body>
var currentDisplay = newNode.style.display; newNode.style.display = ‘none’; parentNode.insertBefore(newNode, componentNode);
maybe it is because of angular 6 ?