CSS selector limitations complicate fixing unintended style applications.
The issue involves a CSS selector in common.css that incorrectly applies styles to elements with custom CSS variables containing 'border-width'. The fix requires careful consideration of CSS selector limitations and potential impacts on global styles. A maintainer suggests waiting for CSS regex support or reworking global styles logic.
Description:
In the file common.css from the Gutenberg plugin, there's a global selector:
html :where([style*=border-width]) {
border-style: solid;
}
This selector unintentionally matches inline styles containing custom CSS variables such as:
<div style="--fir-list-border-width: 1px;"></div>
…which results in the element receiving border-style: solid, even though no actual border-width property is defined. This causes unwanted borders to appear in custom blocks and themes using custom CSS variables.
<div style="--my-custom-border-width: 1px;"></div>Expected Behavior:
The selector should only apply border-style: solid if a real border-width is declared, not when custom variables containing the substring border-width are used.
Suggested Fix:
Avoid using broad attribute selectors like [style*=border-width]. Instead:
Workaround:
Add border width 0 to border wrapper options, …but this should not be necessary, as the default border should be none, if the border option is not set.
Claim this issue to let others know you're working on it. You'll earn 20 points when you complete it!