Repository navigation
Conversation
| -webkit-mask-composite: xor; | ||
| mask: url(full.png); | ||
| mask-composite: exclude; | ||
| } No newline at end of file |
There was a problem hiding this comment.
Add new line to the end of the file please
There was a problem hiding this comment.
Done in c29be60, also in mask-composite.out.css.
| let vendor = require('../vendor') | ||
|
|
||
| class MaskComposite extends Declaration { | ||
| /** |
There was a problem hiding this comment.
This comment is not very useful. We need to explain for (let step of [-1, 1]) { and other complex part not explaining things obvious from isAlready
There was a problem hiding this comment.
Rewritten in c29be60. The comment now shows the rule that goes wrong (-webkit-mask, -webkit-mask-composite, mask) and why the default check stops early. The loop over [-1, 1] is gone. Each direction is a call to a small groupHas(decl, prefixed, direction) with its own comment, and the stop conditions sit in endsGroup(), each explained.
| isAlready(decl, prefixed) { | ||
| let nodes = decl.parent.nodes | ||
| let index = nodes.indexOf(decl) | ||
| for (let step of [-1, 1]) { |
There was a problem hiding this comment.
This code is too complicated, can we make it more readable?
There was a problem hiding this comment.
Split it up in c29be60: isAlready() is one line that checks up and then down, groupHas() walks one direction, and endsGroup() holds the three stop conditions. Behaviour is unchanged. All 289 tests pass, and the mask-composite case still fails on the old code.
Fixes the duplicate
-webkit-maskand-webkit-mask-compositethat Autoprefixer adds when the rule already has-webkit-mask,-webkit-mask-composite,maskin that order (the common gradient border pattern).Declaration.isAlready()usesprefixes.group(), which stops at-webkit-mask-compositebecause its unprefixed name differs frommask.MaskCompositenow overridesisAlready(). It looks at the neighbouringmaskandmask-compositedeclarations, in both directions, past each other. It stops at the next unprefixed declaration of the same property, asgroup()does. It also stops at amaskdeclaration that Autoprefixer already inserted a composite for. That way a latermask-compositestill gets its own-webkit-mask-composite. The marker is the property_autoprefixerMaskCompositeon the declaration, like_autoprefixerMaxand_autoprefixerCascadeinlib/declaration.js. It is not printed and does not change the output text.Behavior change: a rule that already has
-webkit-maskor-webkit-mask-compositeinside its mask run no longer gets a second copy. This also means a second Autoprefixer run on the same CSS (or on the same PostCSS root) no longer adds more lines. Nothing else in the output changes. I did not touch-webkit-mask-*longhands, uppercase hand-written prefixes, or other properties placed between the mask declarations. Those behave as before.Tests: two new cases in
test/cases/mask-composite.css. Before the fix thesupports mask-compositetest fails. After the fixnode node_modules/uvu/bin.js . '\.test\.js$'gives 289 passed, 0 failed on my machine.oxlintandoxfmt --checkare clean on the changed file, and the coverage check (c8, 100% lines) passes locally.I also ran a random comparison against main on 30000 rules (hand-written prefixed and unprefixed mask declarations,
!important, comments, upper case,@mediaand@supports, six browser queries). When a rule has no hand-written-webkit-mask*, the output is identical to main (0 changed out of all such rules). When it has one, the fix output is the main output with some lines removed, never with lines added or reordered (128 rules). The fix output is stable on a second run for all 30000, main is not for 1206.Fixes #1573
Validated with Claude Opus 5.5.