angular / angular.js

AngularJS - HTML enhanced for web apps!
https://angularjs.org
MIT License
58.85k stars 27.52k forks source link

$animate.leave causes IE error if raw DOM element passed #15081

Open adamreisnz opened 8 years ago

adamreisnz commented 8 years ago

Do you want to request a feature or report a bug? Bug

What is the current behavior? Calling $animate.leave() with a raw DOM element as parameter will cause an Object doesn't support property or method remove error in IE 10/11.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://plnkr.co or similar (template: http://plnkr.co/edit/tpl:yBpEi4).

let ele = $document[0].getElementById('some-id')
$animate.leave(ele);

What is the expected behavior? It works in other browsers, because they support the DOM element .remove() method. However, as this is not supported in IE, I would think that Angular should check if the object passed into the function is in fact a jQlite wrapped object or a raw DOM element, and give a warning if it's not a jQlite wrapped object or possibly wrap it by itself.

What is the motivation / use case for changing the behavior? Warn developers of potential problems in IE.

Which versions of Angular, and which browser / OS are affected by this issue? Did this work in previous versions of Angular? Please also test with the latest stable and snapshot (https://code.angularjs.org/snapshot/) versions. Angular 1.5.8 IE 10, 11

Other information (e.g. stacktraces, related issues, suggestions how to fix) The following line is what's causing it: https://github.com/angular/angular.js/blob/0ff10e1b56c6b7c4ac465e35c96a5886e294bac5/src/ng/animate.js#L509

gkalpak commented 8 years ago

According to the docs, the elements passed to the $aminate functions are regular DOM Nodes, but we clearly assume they are jqLite/jQuery elements.

Ideally we should only support jqLite/jQuery elements, but "fixing" that would be a breaking change (since it's been documented otherwise for a long time). I think we should support both (which should be fairly straight-forward anyway).