Home > cannot read > childnodes error

Childnodes Error

Contents

Cannot Read Property "childNodes" Of Undefined In AngularJS By Ben Nadel on August 20, 2015 Tags: Javascript / DHTML The other day at InVision, we launched some code that worked fine locally, fine in QA, fine cannot read property 'childnodes' of undefined angularjs in Staging, and fine in Production - except for a small set of users.

Cannot Read Property 'childnodes' Of Undefined At Compositelinkfn

For just a few people, the page was completely breaking with the AngularJS-initiated JavaScript error, "TypeError: Cannot Read Property 'childNodes' Of Undefined." cannot read property 'childnodes' of null javascript After the customer support team dug into the tickets, they noticed a trend that most of the users were in Europe; and, that most of the users had the "CookiesOK" Google Chrome plugin installed. It turns

Cannot Read Property 'childnodes' Of Undefined Ionic

out, this was just one of a number of Google Chrome plugins that can [potentially] disrupt the AngularJS compile and linking lifecycle.I've tried to follow the AngularJS compile and linking code to figure out exactly what is going wrong. But, to be honest, the code is a bit too complicated for me to trace effectively. I understand, at a high level, what is going wrong; but, I cannot determine the low-level landscape cannot read property 'childnodes' of undefined javascript of details. Ultimately, the error has to do with the fact that the DOM (Document Object Model) is being altered indirectly, by a Controller, during the compile and linking phase. The alteration of the DOM throws the internal tree-walker out of whack and we end up referencing an undefined node.In our particular case, the problem relates to a breakdown in the separation of concerns between module types. In AngularJS, the Controller is not supposed to know anything about the DOM. And, to that extend, it probably shouldn't load any services that mutate the DOM. But, that's exactly what we were doing - we were loading a service that was injecting a 3rd-party Script element as part of its initialization.The Controller was [indirectly] mutating the DOM, which is a big no-no in AngularJS.On its own, this may not have been a problem - or rather, the problem may never have become symptomatic. But, for users that had certain Google Chrome plugins installed, the page would break because the plugins themselves were injecting Script tags into the HTML element of the page. The 3rd-party script tags would then getting injected before the plugin-injected tags, and that's what was breaking everything.To get a sense of what I'm talking about, here is an isolated use-case:

here for a quick overview of

Cannot Read Property 'childnodes' Of Undefined Ui Router

the site Help Center Detailed answers to any questions

Cannot Read Property 'childnodes' Of Null Lightning

you might have Meta Discuss the workings and policies of this site About typeerror cannot read property of undefined angular Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions http://www.bennadel.com/blog/2892-typeerror-cannot-read-property-childnodes-of-undefined-in-angularjs.htm Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up TypeError: Cannot read property 'childNodes' of http://stackoverflow.com/questions/27560826/typeerror-cannot-read-property-childnodes-of-undefined-angular undefined angular up vote 6 down vote favorite I am stuck with this error, am having a custom directive for creating a bar chart, which gets generated from a json file. Here is my code, I have a Index.Html page, where one view is routed inside based on the navigation here is the Index.Html DiginRt