Skip to content

<content> select should only match children. #787

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

Merged
merged 2 commits into from
Apr 17, 2015

Conversation

nkovacs
Copy link

@nkovacs nkovacs commented Apr 16, 2015

Fixes #786

? selected
: outlet.childNodes
)
if (selected.length) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One possible issue here: if all nodes in selected are nested ones (thus should be filtered out), we end up outputting empty content, but in that case we should actually use the fallback content (outlet.childNodes).

According to http://w3c.github.io/webcomponents/spec/shadow/#dfn-pool-distribution-algorithm, the algorithm here should be:

  • For each direct child node of raw, check if it matches select.
  • If yes, push it into selected.
  • If selected ends up empty, use outlet.childNodes instead.

This also means we need a matches() helper in util/dom.js:

var p = Element.prototype
var matches = p.matches || p.webkitMatchesSelector || p.mozMatchesSelector || p.msMatchesSelector
exports.matches = function (el, selector) {
  return matches.call(el, selector)
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to avoid element.matches because its browser support is slightly worse than querySelectorAll (http://caniuse.com/#feat=matchesselector vs http://caniuse.com/#search=queryselectorall). In practice it probably doesn't matter (opera mini 8 is the only browser that's still used of those, and I don't know if vue even supports it), but I decided to play it safe.

Fallback wasn't used when none of the nodes matched by the selector
were children of the target.

refs vuejs#786
yyx990803 added a commit that referenced this pull request Apr 17, 2015
<content> select should only match children.
@yyx990803 yyx990803 merged commit 9099bd6 into vuejs:dev Apr 17, 2015
yyx990803 added a commit that referenced this pull request Apr 17, 2015
@yyx990803
Copy link
Member

Thanks!

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

Successfully merging this pull request may close these issues.

<content> select should only select children
2 participants