Fix: deduplicate unparsed -webkit-mask declarations#1295
Open
franciscolourenco wants to merge 1 commit into
Open
Fix: deduplicate unparsed -webkit-mask declarations#1295franciscolourenco wants to merge 1 commit into
franciscolourenco wants to merge 1 commit into
Conversation
Authored `-webkit-mask` + `mask` pairs with unparsed values (e.g. var()) produced a duplicate `-webkit-mask` when targets require prefixing the unprefixed property. Merge the vendor prefixes into the previous declaration when the property and value are identical, instead of pushing a duplicate. The merge only applies to adjacent declarations, since merging across an intervening declaration could change the cascade (e.g. a longhand reset by a later shorthand). The same merge is applied to generated @supports color fallbacks, which were registered once per authored declaration and kept the duplicate even when the main rule was deduped.
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.
-webkit-maskis currently duplicated when a rule contains an authored prefix pair with a value it can't fully parse (e.g. containingvar()):Resulting in:
With targets that require prefixing
mask,-webkit-maskgets duplicated when the author already wrote one. Parsed values don't have this problem because the mask handler already accumulates prefixes for them. This is another case of #403 and #237With this PR, if the previous declaration is the same property with an identical value, we merge the vendor prefixes into it instead of pushing a duplicate. The same merge is applied to generated
@supportscolor fallbacks, which are registered per authored declaration and would otherwise keep the duplicate.Only adjacent declarations are merged, since
maskis a shorthand and merging across an intervening declaration (e.g. amask-imagethat the latermaskresets) could change the cascade. Merging also requires exact token equality, so identical duplicate declarations collapse too, which is cascade-neutral.The logic lives in a small helper (
UnparsedProperty::merge_prefixes_into_last) since the same bug exists in other handlers (transition, animation, transform, border-radius) — those are left for follow-ups to keep this focused, as is themask-border/-webkit-mask-box-imagepair, which needs property mapping rather than prefix normalization. The approach follows #850, which fixed the same kind of duplicate insidetransition-propertyvalues, and doesn't overlap with #1259/#1284, which fix a sibling bug in the parsedbackdrop-filterpath.Related to #969