-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Try: Cover block image rules, very high specificity. #28412
Conversation
Size Change: +265 B (0%) Total Size: 1.39 MB
ℹ️ View Unchanged
|
// The extra specificity here helps scope the rules. | ||
// The rules have the !important suffix, to protect the behavior from theme CSS bleed. | ||
img.wp-block-cover__image-background, | ||
video.wp-block-cover__video-background { |
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.
On first thought, I was thinking that it might be better to remove the .wp-block-cover-image, .wp-block-cover
scope and the img
and video
scope, but I haven't thought of a single reason why these styles should need to be overridden since overriding many of them would just break the expected behavior.
outline
, border
, and box-shadow
are the only ones that aren't size/positioning related, so maybe the scope could be lightened up on those, but I think the rest need it.
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.
Those three rules are all speculative in that I've seen rules that touch those, but not in recent themes. But that's sort of the arms race with the bleed that can happen.
I like keeping the specificity uniform, though — themes really really shouldn't touch those properties.
However I'm also happy that we started out with the other branch that isn't nuclear like this one. I hope that's sufficient so we can close this one! 🤞
Going to close this one for now. We can revisit if adjacent issues resurface! |
This PR is a copy of #28404, but is separate because the changes are pretty opinionated. That lets us try a milder approach in the original branch, and this pretty heavy approach separately.
The bulk of the change is to be found in this commit: b15d1da, which adds additional selectors and suffixes them with !important.
The reason that inspired that change is TwentyEleven, which has this CSS:
It reminded me that the
img
element is almost always styled by themes in numerous creative ways. If we don't anticipate themes doing this, it's likely the cover block, which now uses the image in a purely mechanical way, will suffer all kinds of CSS bleed.So by anticipating what might bleed in here, the hope is that we make the cover and its use of image, more resilient to that same bleed.
I almost always try to avoid !importants, but this seems like the right place for it.
Here's TwentyEleven shown in #28404:
Here it is, in this branch:
This branch, frontend: