Skip to content

Fix: deduplicate unparsed -webkit-mask declarations#1295

Open
franciscolourenco wants to merge 1 commit into
parcel-bundler:masterfrom
franciscolourenco:fix/mask-prefix-merge
Open

Fix: deduplicate unparsed -webkit-mask declarations#1295
franciscolourenco wants to merge 1 commit into
parcel-bundler:masterfrom
franciscolourenco:fix/mask-prefix-merge

Conversation

@franciscolourenco

@franciscolourenco franciscolourenco commented Jul 15, 2026

Copy link
Copy Markdown

-webkit-mask is currently duplicated when a rule contains an authored prefix pair with a value it can't fully parse (e.g. containing var()):

.foo {
  -webkit-mask: url(mask.svg) var(--offset);
  mask: url(mask.svg) var(--offset);
}

Resulting in:

.foo {
  -webkit-mask: url(mask.svg) var(--offset);
  -webkit-mask: url(mask.svg) var(--offset);
  mask: url(mask.svg) var(--offset);
}

With targets that require prefixing mask, -webkit-mask gets 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 #237

With 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 @supports color fallbacks, which are registered per authored declaration and would otherwise keep the duplicate.

Only adjacent declarations are merged, since mask is a shorthand and merging across an intervening declaration (e.g. a mask-image that the later mask resets) 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 the mask-border/-webkit-mask-box-image pair, which needs property mapping rather than prefix normalization. The approach follows #850, which fixed the same kind of duplicate inside transition-property values, and doesn't overlap with #1259/#1284, which fix a sibling bug in the parsed backdrop-filter path.

Related to #969

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.
@franciscolourenco franciscolourenco changed the title Fix: Deduplicate unparsed -webkit-mask declarations Fix: deduplicate unparsed -webkit-mask declarations Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant