Allow to use scoped (':scope' and '&') selectors relative to controller's element in outlets selectors#888
Open
christophehenry wants to merge 1 commit into
Conversation
…er's element in outlets selectors
11f2382 to
4c9d41b
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This allow to use the concept of outlets to express component composition. Take the following:
This allows to reference
custom-itemoutlets only within the scope ofcustom-selectcontroller's element. Of course you could solve this by setting an id on everycustom-selectcontroller's element and referencing it in outlet's selector but this is not always convenient since HTML code can be generated and not easy to customize. Plus, scope selectors (&and:scope) are a things in most browsers now.What it does is, if
element.matches(selector)returns false, the code will additionnaly perform aquerySelectorAll(selector)on the controller's element nand tests if the element appears in the results. This is additionnal work but I expect performance impact to be very limited since this additionnal test will only be performed if the first match fails, I expectquerySelectorAllto be highly optimized on modern browsers and I expect the controller's element to have a limited nuber of nodes mode of the time. The performance penalty could, however, be mitigated by pushing whatwg/dom#1081 into the standards.