angular.js icon indicating copy to clipboard operation
angular.js copied to clipboard

fix(IE8+JQuery): "Object doesn't support this property or method" on route change

Open jonbcard opened this issue 13 years ago • 7 comments

Not sure of the detailed route cause on this one yet, but Angular 1.1.2 seems to have a regression around the $routeChangeSuccess event when used on IE8 w/ JQuery . While the update() method is running, it bombs out while calling

element.contents().data('$ngControllerController', controller);

JSFiddle showing the issue: http://jsfiddle.net/HsQRN/6/ Note that the new route doesn't load correctly, and that there is a console error. Works fine with 1.0.4, or without JQuery.

Edit: Updated the JSFiddle

jonbcard avatar Jan 24 '13 21:01 jonbcard

I am seeing this issue on Angular 1.0.4 as well. Issue does not exist in 1.0.3.

kloy avatar Jan 29 '13 02:01 kloy

sounds like we need to use element.children().... instead of element.contents()...

IgorMinar avatar Jan 29 '13 06:01 IgorMinar

@kloy : Oops! You're totally right -- 1.0.4 is broken too. I guess I only tested that it was working in 1.0.2 and 1.0.3. Thanks for setting that straight.

@IgorMinar : Yup! You are right switching to children() there helps -- its no longer trying to do the setData on the text node -- but then just a few lines later during the link() it tries to do it again and dies due to change in 49f9e4cef13e68ff85b3c160cf8fac6e7cd042a3

jonbcard avatar Jan 29 '13 17:01 jonbcard

Are you guys working on a fix? Or can you maybe provide me with a hint, so I could try making a patch myself.

jafp avatar Jan 31 '13 08:01 jafp

@jafp If you need a temporary fix for it you can remove the line added in 49f9e4cef13e68ff85b3c160cf8fac6e7cd042a3 but then of course you are re-introducing the transclusion issue it was meant to fix. That's what I'm doing.

I assume that this will probably be fixed by on of the following methods:

  1. Pick through all the places that data() is being used and make sure it is being done appropriately (ie. not trying to assign to text nodes now that wrapper spans are not being written). I'm run into two now, and I'm sure there are more.
  2. Drop in another JQLitePatchJQuery for data() to make these calls less error sensitive if the node handle has bad nodes? This one might be weird, and I honestly haven't looked at the JQLite code to see how its handling the call.
  3. Revert 49f9e4cef13e68ff85b3c160cf8fac6e7cd042a3 and fix https://github.com/angular/angular.js/issues/1059 some other sneaky way. Still means the DOM is getting polluted with extra markup it doesn't need, though.

Personally I didn't dare mess with a PR on this one myself since it could be a little bit sticky given the potential for further regressions.

jonbcard avatar Jan 31 '13 15:01 jonbcard

Fixed in 791804bdbfa6da7a39283623bd05628a01cd8720

petebacondarwin avatar Feb 18 '13 13:02 petebacondarwin

I think the issue Pete fixed has returned. I get the TypeError message in IE8 when using templates. Replacing all instances of .contents() with .children() in the debug file fixed the problem.

rwhitmire avatar Dec 04 '13 13:12 rwhitmire