Repository navigation
v0.17.1
Fixed
- Token values with an unclosed quote, comment, parenthesis or square bracket, a stray
)or], or a trailing backslash are now skipped with a warning, like values with;,{or}, byWaveProvider tokensandgetTokenStyle; before, in a server-renderedstyleattribute such a value swallowed the declarations after it (the later overrides and yourstyle), so the server and the client could render different overrides (the 0.17.0 note that both render the same overrides held for well-formed values only). The value is scanned once, as the CSS tokenizer reads it: parentheses and brackets inside a string or a comment, the other quote inside a string and escapes inside a string do not count, a string must close on its own line, and a closer must match the innermost open parenthesis or bracket. Every token oftokens.css, font stacks with quoted names such as'Segoe UI Web (West European)', shadows, curves,var()with a fallback andcolor-mix()still pass. - Token values that hold
url((in any case), or a!or a backslash outside strings and comments, are skipped with the same warning. No token takes a URL, and an unquoted URL ends at its first)whatever it holds, sourl(a"b)c")opened a string after it that swallowed the later declarations on the server, and so did the same URL spelt with an escape (u\72l(a"b)c"),\75 rl(…)), which nourl(test sees; the server readred !importantasredwith the important priority, while the client refuses the value. A backslash inside a string ('Wave\'s Sans') is still an escape. - Token values are trimmed (JavaScript's
trim) before they are applied. React's server renderer trims a custom property's value while the client sets it as given, so a value with a no-break space, a byte order mark, a vertical tab or a line or paragraph separator at an edge painted on the server-rendered root and fell back on the client-rendered portals (' red'with a no-break space). A value that is empty after trimming sets nothing, on the server and in the client. - After these fixes every value
tokensandgetTokenStyleapply is trimmed, balanced CSS text without;,{,}orurl(and with no!or backslash outside strings and comments, which the server-renderedstyleattribute and the client read alike, so the server and the client render the same overrides. Checked in Chromium 156 for each of these cases and for 400,000 generated values (quotes, comments, brackets, escapes,url(,!important,<!--and-->,@rules,U+ranges and the edge spaces), of which none of the 97,560 that pass read differently; in review, a tokenizer that follows CSS Syntax Level 3 found none of the 337,195 that pass among 2,000,000 values that swallows or alters another declaration. - The check is one pass over the value, its stack of open parentheses and brackets an array, so its time grows with the length of the value alone: a long value from a tenant's settings cannot stall a server render (
')'.repeat(2 ** 18)takes milliseconds). - Both value warnings now say that a value must be "a finite number, or CSS text with balanced quotes, brackets and comments, without
;,{,}orurl(, and without!or a backslash outside strings and comments".
Changed
WaveProvider'stokenswarnings (WaveProvider:tokens:name:<key>andWaveProvider:tokens:value:<key>) readprocess.env.NODE_ENVwritten out, as the full-ramp check ofcreateBrandTokensdoes, so a production bundle drops them and their text, which keepsWaveProviderwithDialogwithin its budget with the new checks. Development builds warn as before; imported without a bundler (noprocess), the provider skips them.getTokenStyle's warnings are not gated this way.- Dev gates:
verify-distproves the gate, as it doescreateBrandTokens' contrast check: an import of onlyWaveProvider, built for production, holds noWaveProvider:tokens:warning key (HOOK_PROBES_0_17).
Size
Against 0.17.0, measured as its Size table was (verify-dist's measureImport). Sizes are in bytes:
| Import | 0.17.0 | 0.17.1 |
|---|---|---|
An import of only getTokenStyle |
1,350 (772 gzip) | 1,825 (1,018 gzip) |
An import of only WaveProvider |
3,902 (1,844 gzip) | 3,967 (1,883 gzip) |
An import of WaveProvider and Dialog |
73,335 (24,747 gzip) | 73,403 (24,778 gzip) |
getTokenStylegrows by 475 bytes (246 gzip), the checks and the longer warning. In the provider the warnings that a production bundle now drops pay for most of the checks:WaveProvideralone grows by 65 bytes (39 gzip) and withDialogby 68 (31 gzip), within its budget of 73,420 and 24,843. Every other import of the 0.17.0 table, anddist/styles.css, is unchanged.