refactor(css): attribute selectors match web counterparts#7848
refactor(css): attribute selectors match web counterparts#7848
Conversation
with some JavaScript optimization and excluding ProxyViewContainer from the process Change the specificity to be divisible to 10
|
@manoldonev Can you take a look at this? I couldn't find a scenario where there are significant performance gains (the projects mentioned had a different bug), but I think it's good even if only as a refactoring. |
|
I'm working in allowing some layout properties to cascade from ProxyViewContainer to the children, so this breaking change will potentially make it impossible to implement something like CSS Grid. Can this breaking change be clarified or maybe worked around? |
|
The main issue turned out to be elsewhere, so this PR can be reduced to only get the attribute selectors match their web counterparts. |
|
@edusperoni Can you elaborate on your concern about the |
|
@manoldonev Please see the discussion in NativeScript/nativescript-angular#1422 (comment) My current plan is, once we settle on the implementation details of forwarding properties to children, to do: <GridLayout class="grid-container">
<my-component class="grid-header"></my-component>
<my-component class="grid-left"></my-component>
<my-component class="grid-content"></my-component>
<my-component class="grid-footer"></my-component>
</GridLayout>.grid-container {
grid-template-areas: 'header header' 'left content' 'footer footer';
}
.grid-header {
grid-area: header;
}
.grid-left {
grid-area: left;
}
.grid-content {
grid-area: content;
}
.grid-footer {
grid-area: footer;
}GridLayout would then take the children styles and apply row/col to them as required. If we remove the ability for ProxyViewContainer to be matched and properly hold styles, we'll no longer be able to implement grid or add properties that will be forwarded to children (like row/col) in CSS |
* Improve CSS selector parsing/matching by 30% - 40% with some JavaScript optimization and excluding ProxyViewContainer from the process Change the specificity to be divisible to 10 * fix: selector match * fix: lint errors * refactor: restore processing of ProxyViewContainer * chore: lower the number of expected cycles * fix: some css selector fixes Co-authored-by: Manol Donev <manol.donev@gmail.com> Co-authored-by: Manol Donev <manoldonev@users.noreply.github.com> Co-authored-by: Vasil Trifonov <v.trifonov@gmail.com>
PR Checklist
What is the current behavior?
Since the new Theme 2.x produces bigger CSS and uses Element selector styling, the matched elements on the page are more and performance suffers. There are demo projects in the linked issue.
What is the new behavior?
Exclude ProxyViewContainer from the CSS selector matching/init. Optimize some of the matchers and the selector query. Rework the attribute selectors to use exact matching, instead of regular expressions (as is done in browsers).
Fixes/Implements/Closes NativeScript/theme#179.
BREAKING CHANGES:
Classes set on ProxyViewContainer will probably not work anymore. We might consider moving them to the wrapped element - either automatically in core modules or by the user?