-
Notifications
You must be signed in to change notification settings - Fork 62
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
fix: add has polyfill for alignment #2814
fix: add has polyfill for alignment #2814
Conversation
🤖 Pull request artifacts
|
Size Change: +1.5 kB (0%) Total Size: 1.98 MB
ℹ️ View Unchanged
|
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.
I took the liberty of changing some file/script/class names to better reflect the purpose of the newly introduced script.
I have some remaining suggestions / improvements:
- We can have better names for the new classes that can signify that they are polyfill classes:
stk--height-100
➡️stk--height-100-polyfill
stk-container--has-child-column-flex
➡️stk-container--has-child-column-flex-polyfill
- Bring back the specificity of the original selectors you're trying to polyfill, because if not the styles might not be applied correctly.
You're mainly trying to add a class that would have the same effect as the following selectors. But these 2 sets of selectors have different specificities (you can check here: https://specificity.keegan.st/)
:is(.stk-block-content, .stk-inner-blocks):not(.stk--column-flex):has(> :is(.stk--block-margin-top-auto, .stk--block-margin-bottom-auto))
➡️ 3.stk-container:has(> .stk--column-flex)
➡️ 2
The new selectors are just:
.stk--height-100
➡️ 1.stk-container--has-child-column-flex
➡️ 1
That means the styles might get easily overridden by other selectors. You'll need to mimic / bump up the specificity to the same level.
const modifyCSS = () => { | ||
const containers = document.querySelectorAll( '.stk-container' ) | ||
containers.forEach( container => { | ||
const columnFlex = container.querySelector( '.stk--column-flex' ) |
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.
Based on the selector we're trying to mimic, we need this to be for the direct descendent
const columnFlex = container.querySelector( '.stk--column-flex' ) | |
const columnFlex = container.querySelector( ':scope > .stk--column-flex' ) |
} else if ( ! columnFlex && container.classList.contains( 'stk-container--has-child-column-flex' ) ) { | ||
container.classList.remove( 'stk-container--has-child-column-flex' ) |
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.
Do you still need this?
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.
I feel it's odd that Chrome/
is part of the detection for Safari. It should be Safari/
and Version/
and the number after version should be <= 15.3
fixes #2784, fixes #2704