-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
fix getContainedComponents in IE 11 #893
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
Conversation
Is it possible to provide a repro of the error before the fix? |
a6f34ca
to
4ebed2b
Compare
In IE, nextSibling returns a text node, but text node has no method 'contains'. |
while (next !== end) { | ||
next = cur.nextSibling | ||
if (cur.contains(c.$el)) { | ||
isElementNode = cur.nodeType === Node.ELEMENT_NODE | ||
if (isElementNode && cur.contains(c.$el)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix! The situation can be a bit more complicated though, in the case where the component is a block instance (thus its $el
can be a TextNode too).
So I think it's better to change the check to:
if (
cur === c.$el || // both are textNodes
(cur.contains && cur.contains(c.$el)) // other situations
) {
return true
}
@@ -90,7 +90,7 @@ module.exports = { | |||
var next | |||
while (next !== end) { | |||
next = cur.nextSibling | |||
if (cur.contains(c.$el)) { | |||
if (cur.contains && cur.contains(c.$el)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we still need to check the case where cur === c.$el
, because in IE cur.contains
is not present if cur
is a textNode
fix getContainedComponents in IE 11
Merging so you can get credit, I'll fix with tests. :) thanks |
FYI, we had the same issue, and came to the same workaround in testing (+cur.contains(el) on the if directive), but kept digging, and it was triggered by IE9 when doing v-if inside a < template > tag. |
yep, the whole IE family doesn't implement |
No description provided.