Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dom.contains method does not support SVG elements in IE11 #404

Open
jaredgorski opened this issue Jan 21, 2019 · 0 comments
Open

dom.contains method does not support SVG elements in IE11 #404

jaredgorski opened this issue Jan 21, 2019 · 0 comments

Comments

@jaredgorski
Copy link

jaredgorski commented Jan 21, 2019

dom.contains: https://github.com/metal/metal.js/blob/master/packages/metal-dom/src/domNamed.js#L211-L225

We are experiencing an error in IE11 when dom.contains is called in metal-dom in events.js, because we are trying to handle events on an SVG element. We are experiencing this error:
screen shot 2019-01-18 at 12 11 22 pm

When hovering over the ? icon, IE DevTools yields this error:

SCRIPT438: Object doesn't support property or method 'contains'
File: common.js, Line 1, Column 998455

It turns out that IE has limited support of HTML DOM node methods (like Node.contains), as in, it doesn't support searching for an SVG element inside a DOM node. Our use case happens to be causing this function to search inside an SVG element for a path element, which works in Chrome and FF but is invalid in IE11.

@eduardolundgren made a good point about this. According to him, Metal used to have a dom.contains method that used compareDocumentPosition() to compare the position binaries in the DOM tree to see if an element is a descendent of another. A solution like this may bring back full support for contains in IE11. The solution might be identical to this one:
https://github.com/google/closure-library/blob/e656c0807353188f42b67722d56724a5afc13228/closure/goog/dom/dom.js#L1519-L1542

@jbalsas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant