You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: DESIGN.md
+20-17Lines changed: 20 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -51,7 +51,10 @@ pub struct ComponentData {
51
51
pubtemplate:String,
52
52
/// Component CSS content for the Module strategy.
53
53
pubcss:String,
54
-
/// External stylesheet href for the Link CSS strategy (e.g. "/my-card.css").
54
+
/// External stylesheet href for the Link CSS strategy.
55
+
/// Default format is `<component-name>.css`, but build-time naming
56
+
/// templates can produce hashed names (e.g. `my-card-a1b2c3d4.css`) and/or
57
+
/// prepend a CDN/public base URL.
55
58
/// Always set when CssStrategy::Link is active and the component has CSS.
56
59
/// Empty for Style/Module strategies and for components without CSS.
57
60
/// The handler uses `css_strategy` and `dom_strategy` on `WebUIProtocol` to
@@ -441,19 +444,19 @@ pub struct Predicate {
441
444
- Attribute names starting with '?' are treated as boolean attributes using the `Attribute` fragment type with a `condition_tree`. The attribute is rendered only if the condition evaluates to true.
442
445
443
446
## State Management (webui-state)
444
-
### Path Resolution
445
-
The `find_value_by_dotted_path_ref` function provides the render-time state lookup contract:
-**Link** (default): Emits `<link>` tags referencing external `.css` files only for components whose discovery/registration data included CSS. Used by the CLI for production builds where CSS files are served separately.
955
+
-**Link** (default): Emits `<link>` tags referencing external `.css` files only for components whose discovery/registration data included CSS. Used by the CLI for production builds where CSS files are served separately. Output filenames are configurable with a naming template (`[name]`, `[hash]`, `[ext]`), defaulting to `[name].[ext]`. `[hash]` is SHA-256 truncated to 8 hex chars. An optional public base prefix can be applied so protocol `css_href` values point to CDN URLs. The resolved href is used consistently for handler-emitted head links and parser/plugin-generated component template stylesheet links.
953
956
-**Style**: Embeds the full CSS content in `<style>` tags inside the shadow DOM template. Used when all files are needed in-memory.
954
957
- **Module**: Uses the [Declarative CSS Module Scripts](https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/main/ShadowDOM/explainer.md) proposal. During SSR, emits a `<style type="module" specifier="component-name">` definition in each component's light DOM on first render (e.g., `<my-comp><style type="module" ...>CSS</style><template ...>`) and adds `shadowrootadoptedstylesheets="component-name"` to each shadow root `<template>`. Components inside false `<if>` blocks or empty `<for>` loops that were not rendered during SSR get their module style definitions emitted at `body_end`, so client-side activation can adopt them. When a CSP nonce is configured (via `RenderOptions::with_nonce` / `webui_handler_set_nonce`), the SSR-emitted `<style type="module">` tags include `nonce="VALUE"` (in `type`, `nonce`, `specifier` order) so strict `style-src 'nonce-...'` policies allow them, matching the existing nonce treatment of inline `<script>` tags. The browser registers the CSS module globally and shares a single `CSSStyleSheet` across all shadow roots that adopt it. No external CSS files are produced. During SPA partial navigation, module style definitions for newly needed components are sent in the `templateStyles` array; the router appends them to `<head>` before executing template scripts. WebUI Framework compiled metadata carries the adopted stylesheet specifier (`sa`) so client-created components can adopt the registered stylesheet on their shadow root.
955
958
956
-
Set via `parser.set_css_strategy(CssStrategy::Style)`.
959
+
Set at construction time with `HtmlParser::with_options(ParserOptions::try_new(...))`.
0 commit comments