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.

Cannot read property 'appendChild' of null

See original GitHub issue

Hi,

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:closed
  • Created 4 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
chrumcommented, Dec 17, 2019

just officially published it with couple other things i had in dev branch…

thanks and best!

0reactions
turbobuiltcommented, Jul 9, 2020

Still have this issue on 1.8.0

Read more comments on GitHub >

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

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