-
Notifications
You must be signed in to change notification settings - Fork 27.4k
DOMTokenList causes errors with copy() and forEach() #11665
Comments
I've verified that both the Chrome issue and the FireFox issue can be traced back to the property removal. Replacing the
fixes it in both. |
This is our code that is causing the problem:
It's part of some click detection code, so we can disable links if they have the |
@herrevilkitten putting aside problem with So I think there are 2 problems in this issue:
|
Yes. I'm looking at ways to make this more appropriate. Thanks for looking at this. |
@herrevilkitten yes, OK, glad that you've decided to refactor things on your end. As I've said before, I don't think we want to support DOM nodes coping as part of AngularJS core. |
I had the same issue the way I fix it was just replacing |
honestly that just sounds like your typescript .d.ts file needs work |
Thanks a lot herrevilkitten. Replacing that forEach fixed my problems and got my application to work again. Saved my day. I hope angular will put that into their source code. |
There's an open issue: angular/angular.js#12004 this fix was taken from angular/angular.js#11665
Assume that there is an object and one of its properties is an object with
DOMTokenList
as its prototype. In Chrome and FireFox, this will cause different errors when copying the object. In both cases, the error actually occurs inforEach()
.For Chrome:
Chrome will throw an exception at line 267 (of Angular.js) because its version of
DOMTokenList
implements its own version offorEach
, which causes aninvalid invocation
error.For FireFox:
FireFox will throw an exception at line 203 (of Angular.js) because of the following:
(in copy)
...
...
(in isArrayLike)
Essentially, the problem is this:
DOMTokenList
has a read-only length property. As an interface, this requires that its implementing object define alength
property. A new, empty object is created. It is then iterated over in order to delete any existing properties. During this iteration,forEach()
callsisArrayLike()
, which subsequently checks to see if there is alength
property. This causes an error, as the read-only property is checked and does not exist on the object.The FireFox issue may also be causing the Chrome issue. I have not fully tested this.
My current workaround is to comment out the part where it calls the native
forEach
and to change the property removal to just be afor
loop.The text was updated successfully, but these errors were encountered: