Skip to content

v0.17.1

Choose a tag to compare

@github-actions github-actions released this 30 Oct 06:47
· 287 commits to main since this release

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 }, by WaveProvider tokens and getTokenStyle; before, in a server-rendered style attribute such a value swallowed the declarations after it (the later overrides and your style), 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 of tokens.css, font stacks with quoted names such as 'Segoe UI Web (West European)', shadows, curves, var() with a fallback and color-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, so url(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 no url( test sees; the server read red !important as red with 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 tokens and getTokenStyle apply is trimmed, balanced CSS text without ;, {, } or url( and with no ! or backslash outside strings and comments, which the server-rendered style attribute 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 ;, {, } or url(, and without ! or a backslash outside strings and comments".

Changed

  • WaveProvider's tokens warnings (WaveProvider:tokens:name:<key> and WaveProvider:tokens:value:<key>) read process.env.NODE_ENV written out, as the full-ramp check of createBrandTokens does, so a production bundle drops them and their text, which keeps WaveProvider with Dialog within its budget with the new checks. Development builds warn as before; imported without a bundler (no process), the provider skips them. getTokenStyle's warnings are not gated this way.
  • Dev gates: verify-dist proves the gate, as it does createBrandTokens' contrast check: an import of only WaveProvider, built for production, holds no WaveProvider: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)
  • getTokenStyle grows 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: WaveProvider alone grows by 65 bytes (39 gzip) and with Dialog by 68 (31 gzip), within its budget of 73,420 and 24,843. Every other import of the 0.17.0 table, and dist/styles.css, is unchanged.