Cannot read property 'appendChild' of null
See original GitHub issueHi,
Just installed ngx-autosize
. Works great but got this error thrown just now (see below). Quite probably because I dynamically display / hide the textarea
onto which autosize
is applied, but I can’t reproduce it at will 😕.
Cannot read property 'appendChild' of null
at AutosizeDirective.adjust (ngx-autosize.js:137)
at ngx-autosize.js:111
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423)
at Object.onInvokeTask (core.js:21826)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:422)
The culprit line is
const parent = this.textAreaEl.parentNode;
clone.style.width = this.textAreaEl.offsetWidth + 'px';
clone.style.visibility = 'hidden';
clone.style.position = 'absolute';
clone.textContent = currentText;
parent.appendChild(clone); <------- HERE
There should probably be a if (!parent) return
or something somewhere in there.
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Uncaught TypeError: Cannot read property 'appendChild' of null
The "Cannot read property 'appendChild' of null" error occurs for 2 reasons: Calling the appendChild() method on a DOM element that doesn't ...
Read more >TypeError: Cannot read property 'appendChild' of Null in JS
The "Cannot read property 'appendChild' of null" error occurs when trying to call the appendChild method on a DOM element that doesn't exist....
Read more >Cannot read properties of null (reading 'appendChild ... - Reddit
It means your variable main is null, and therefore it has no property by the name appendChild . It's effecively trying to do...
Read more >"Cannot read property 'appendChild' of null" when creating a ...
"Cannot read property 'appendChild' of null" error occurs when creating a variable of ol.style.RegularShape before document is loaded Steps ...
Read more >klaviyo form error "Cannot read property 'appendChild' of null
klaviyo form error "Cannot read property 'appendChild' of null ... When the form doesn't load it returns the following console error.
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
just officially published it with couple other things i had in dev branch…
thanks and best!
Still have this issue on 1.8.0