Repository navigation
fix(core): keep the styles of a composition whose id contains $ patterns - #8141
Conversation
…me and in the runtime script
Edit accuracy: accurate 271 (base branch 271), smooth 50 of thoseThe gate passes. Quarantined, measured but not gated (0) |
terencecho
left a comment
There was a problem hiding this comment.
Reviewed at f55c0c5. No blocking correctness, security, or data-loss finding.
All three compile-time replacements and four emitted runtime replacements insert the selector through callbacks, so replacement-string dollar sequences cannot reinterpret the composition id. The two golden updates match the emitted helper and callback changes.
Validation: full workspace build passed; all 90 composition-scoping and page-build golden tests passed. Reverting the compile-time callback changes makes all three named dollar-id regressions fail; restoring them passes. Three additional temporary runtime lookup probes also passed with an explicit mount selector. No real-browser render was performed. At the final check, three CI jobs were still running and none had failed.
— tai (automated review)
What
A composition whose id contains
$&,$'or$`now keeps its styles in preview and render. Before, scoping a stylesheet to that composition pasted the matched text, or the rest of the selector, into the selector in place of the id, so the rule stopped matching its elements and the selector grew by the text around it. An id ofa$'bturned[data-composition-id="a$'b"] .titleinto[data-composition-id="a .titleb"] .title.Why
Scoping rewrites a selector naming the composition, or its root with
data-start/data-duration, to the composition's own scope selector. It did that withString.prototype.replace(pattern, scope), and a replacement string reads$&,$',$`and$1as patterns. The scope selector carries the composition id, which comes from the project's HTML, so those patterns in an id were expanded instead of written. The script that scopes a composition's own selectors at runtime made the same call with the same value.Related work
None.
How
compositionScoping.ts: the three compile-time rewrites pass a function,() => scope, so the scope is inserted as text.__hfRootSelectorText, used by its fourreplacecalls.Test plan
packages/core/src/compiler/compositionScoping.test.ts(one case each fora$'b,a$`banda$&b), the first commit. Without the fix all three fail;a$'bcame out as[data-composition-id="a .titleb"] .title.packages/corecompiler and runtime pass 4,036 of 4,038 tests; the other 2 were the page-build goldens, which this branch now updates;querySelector(__hfRootSelector)call left alone). CI'spageBuild.golden.test.tschecks them.