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
feat: change default attribute-name-strategy from none to camelCase (#7479)
# Pull Request
## 📖 Description
Changes the default `attribute-name-strategy` from `"none"` to `"camelCase"` across the FAST monorepo. This applies to:
- **`microsoft-fast-build` Rust crate**: The `AttributeNameStrategy` enum's `#[default]` is moved from `None` to `CamelCase`
- **`@microsoft/fast-build` CLI**: Default strategy passed to the WASM renderer and CLI help text updated
- **`@microsoft/fast-html` AttributeMap**: Default fallback changed from `"none"` to `"camelCase"`
With this change, dashed HTML attribute names on custom elements (e.g. `foo-bar`) are now converted to camelCase state keys (e.g. `fooBar`) by default. The `"none"` strategy remains available as an explicit opt-in.
## 📑 Test Plan
- All existing Rust tests pass (`cargo test`)
- All Playwright tests pass (`npm run test`)
- All fixtures rebuilt successfully (`npm run build:fixtures`)
- Biome check passes (`npm run biome:check`)
- Change files validated (`npm run checkchange`)
## ✅ Checklist
### General
- [x] I have included a change request file using `$ npm run change`
- [ ] I have added tests for my changes.
- [x] I have tested my changes.
- [x] I have updated the project documentation to reflect my changes.
- [x] I have read the [CONTRIBUTING](https://github.com/microsoft/fast/blob/main/CONTRIBUTING.md) documentation and followed the [standards](https://github.com/microsoft/fast/blob/main/CODE_OF_CONDUCT.md#our-standards) for this project.
Copy file name to clipboardExpand all lines: crates/microsoft-fast-build/tests/custom_elements.rs
+7-5Lines changed: 7 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
mod common;
2
2
use common::{make_locator, empty_root};
3
-
use microsoft_fast_build::{render_template, render_with_locator, render_template_with_locator, render_entry_template_with_locator,Locator,RenderError};
3
+
use microsoft_fast_build::{render_template, render_with_locator, render_template_with_locator, render_entry_template_with_locator,Locator,RenderError,RenderConfig,AttributeNameStrategy};
4
4
5
5
// ── attribute → state mapping ─────────────────────────────────────────────────
Copy file name to clipboardExpand all lines: packages/fast-build/DESIGN.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -148,7 +148,7 @@ Three WASM functions are used:
148
148
| Function | Used when |
149
149
|----------|-----------|
150
150
|`wasm.render(entry, state)`| No custom element templates |
151
-
|`wasm.render_entry_with_templates(entry, templatesJson, state, strategy)`| At least one template was loaded. `strategy` is `"none"` or `"camelCase"`. |
151
+
|`wasm.render_entry_with_templates(entry, templatesJson, state, strategy)`| At least one template was loaded. `strategy` is `"camelCase"` or `"none"`. |
152
152
|`wasm.parse_f_templates(html)`| Parsing `<f-template>` elements from each matched HTML file |
153
153
154
154
`templatesJson` is a JSON-stringified object mapping element names to their raw inner template strings (the content extracted from `<template>` inside `<f-template>`). The WASM renderer uses this map to resolve custom element tags and inject Declarative Shadow DOM.
Copy file name to clipboardExpand all lines: packages/fast-build/README.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,7 +39,7 @@ fast build [options]
39
39
|`--state="<path>"`|`state.json`| JSON file containing the template state |
40
40
|`--output="<path>"`|`output.html`| Where to write the rendered HTML |
41
41
|`--templates="<glob>"`|_(none)_| Glob pattern(s) for custom element template HTML files. Separate multiple patterns with commas. A warning is printed if not provided or if no files match a pattern. |
42
-
|`--attribute-name-strategy="<strategy>"`|`none`| Strategy for mapping HTML attribute names to state property names on custom elements. `"none"`preserves dashes (e.g. `foo-bar` → `foo-bar`). `"camelCase"`converts dashes to camelCase (e.g. `foo-bar` → `fooBar`). See [Attribute name strategy](#attribute-name-strategy). |
42
+
|`--attribute-name-strategy="<strategy>"`|`camelCase`| Strategy for mapping HTML attribute names to state property names on custom elements. `"camelCase"`converts dashes to camelCase (e.g. `foo-bar` → `fooBar`). `"none"`preserves dashes (e.g. `foo-bar` → `foo-bar`). See [Attribute name strategy](#attribute-name-strategy). |
43
43
|`--config="<path>"`|`fast-build.config.json`| Path to a JSON configuration file. If omitted, `fast-build.config.json` in the current directory is used when present. CLI arguments take precedence over config values. See [Configuration file](#configuration-file). |
44
44
45
45
### Example
@@ -113,8 +113,8 @@ The `--attribute-name-strategy` option controls how HTML attribute names on cust
0 commit comments