Angular.js: "ng-mouseenter" broken in SVG template in Internet Explorer 9-11

Created on 28 Nov 2014  路  5Comments  路  Source: angular/angular.js

IE breaks on the line 3047

if (!related || (related !== target && !target.contains(related))) {

SVG in IE has no "contains" method

example http://jsfiddle.net/4pe5pyn3/

Angular version - 1.3.4

IE10 IE11 IE9 $compile bug

Most helpful comment

I know is more of a hack but until this gets permanently fixed I added a small shim.

    if (typeof SVGElement.prototype.contains == 'undefined') {
        SVGElement.prototype.contains = HTMLDivElement.prototype.contains;
    }

It does the job and doesn't require any core (jqLite) modification.

All 5 comments

I know is more of a hack but until this gets permanently fixed I added a small shim.

    if (typeof SVGElement.prototype.contains == 'undefined') {
        SVGElement.prototype.contains = HTMLDivElement.prototype.contains;
    }

It does the job and doesn't require any core (jqLite) modification.

@ionut-ai Thx for this fix ! It works for me (ng-show buggy on svg element in IE10).

@ionut-ai Where does one put the shim?

I've just spent all morning _(2+ hours)_ investigating the issue.

I'm working in a secure corporate environment with many security policies / restrictions.

On IE11 window.Node is undefined on files loaded from the local file system.

It works on localhost it works on plnkr but when using file protocol it fails...

It took me a while to figure out.

@ionut-ai @Pryscy i am still confused.. do i need to replace the buggy code

var jqLiteContains = window.Node.prototype.contains || /** @this */ function(arg) {
// eslint-disable-next-line no-bitwise
return !!(this.compareDocumentPosition(arg) & 16);
};

with if (typeof SVGElement.prototype.contains == 'undefined') {
SVGElement.prototype.contains = HTMLDivElement.prototype.contains;
}

or do it need to place it somewhere

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jetta20162 picture jetta20162  路  3Comments

butchpeters picture butchpeters  路  3Comments

kishanmundha picture kishanmundha  路  3Comments

WesleyKapow picture WesleyKapow  路  3Comments

nosideeffects picture nosideeffects  路  3Comments