Created
August 9, 2017 07:22
-
-
Save TakayoshiKochi/a7cdfc79a3b985f5d486a0b29171c4ac to your computer and use it in GitHub Desktop.
Replacement for querySelector("::slotted(x)")
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function querySlotted(root, selector) { | |
let slots = root.querySelectorAll('slot'); | |
let matched = []; | |
slots.forEach((slot) => { | |
matched = matched.concat(slot.assignedNodes().filter((el) => { | |
return el.matches(selector); | |
})); | |
}); | |
return matched; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Marvelous, thank you very much!