Skip to content

Commit fc7b7fb

Browse files
janechuCopilot
andcommitted
Remove deprecated declarative event e support
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent f84d40c commit fc7b7fb

31 files changed

Lines changed: 123 additions & 351 deletions

biome.jsonc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
"!**/CHANGELOG.json",
1313
"!change/**/*.json",
1414
"!**/package.json",
15-
"!package-lock.json"
15+
"!package-lock.json",
16+
"!packages/fast-element/test/declarative/fixtures/**/index.html",
17+
"!packages/fast-element/test/declarative/fixtures/**/templates.html"
1618
]
1719
},
1820
"html": {

build/biome-changed.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
import { execFileSync } from "node:child_process";
1919
import { resolve } from "node:path";
2020

21+
const ignoredPaths = [
22+
/^packages\/fast-element\/test\/declarative\/fixtures\/.+\/index\.html$/,
23+
/^packages\/fast-element\/test\/declarative\/fixtures\/.+\/templates\.html$/,
24+
];
25+
2126
const root = execFileSync("git", ["rev-parse", "--show-toplevel"], {
2227
encoding: "utf-8",
2328
}).trim();
@@ -43,6 +48,7 @@ const files = execFileSync("git", gitArgs, {
4348
.trim()
4449
.split("\n")
4550
.filter(Boolean)
51+
.filter(file => !ignoredPaths.some(pattern => pattern.test(file)))
4652
.map(f => resolve(root, f));
4753

4854
if (files.length === 0) {

packages/fast-element/DECLARATIVE_DESIGN.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ All delimiters used by the parser are defined in a single `Syntax` interface and
154154
| `whenDirectiveOpen` / `whenDirectiveClose` | `<f-when` / `</f-when>` | When directive |
155155
| `attributeDirectivePrefix` | `f-` | Attribute directive prefix |
156156
| `eventArgAccessor` | `$e` | DOM event argument |
157-
| `deprecatedEventArgAccessor` | `e` | Deprecated DOM event argument (emits a deduplicated warning once per component) |
158157
| `executionContextAccessor` | `$c` | Execution context argument |
159158

160159
---
@@ -351,7 +350,6 @@ sequenceDiagram
351350
|---|---|---|
352351
| `parse()` | public | Entry point: parses declarative HTML into `{ strings, values }`. |
353352
| `createTemplate()` | public | Creates a `ViewTemplate` from resolved strings and values. |
354-
| `hasDeprecatedEventSyntax` | public | Getter indicating whether the last parse encountered deprecated `e` event syntax. |
355353
| `resolveStringsAndValues()` | private | Creates `strings`/`values` arrays and delegates to `resolveInnerHTML()`. |
356354
| `resolveInnerHTML()` | private | Recursive HTML parser that dispatches to data binding or template directive handlers. |
357355
| `resolveDataBinding()` | private | Thin dispatcher that routes to `resolveContentBinding()`, `resolveAttributeBinding()`, or `resolveAttributeDirectiveBinding()`. |

packages/fast-element/DECLARATIVE_HTML.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -358,15 +358,13 @@ You can pass the DOM event object, the execution context, or both as arguments.
358358
<button @click="{handleClick($e, $c)}"></button>
359359
```
360360

361-
**Arbitrary binding expressions** — any token that is not `$e`, `$c`, or `e` is resolved as a binding path on the data source:
361+
**Arbitrary binding expressions** — any token that is not `$e` or `$c` is resolved as a binding path on the data source:
362362
```html
363363
<button @click="{handleClick(user.id)}"></button>
364364
```
365365

366-
> **Deprecated:** The bare `e` token still works but will emit a console warning once per component. The warning includes the component name to help locate usage. Migrate to `$e`.
367-
> ```html
368-
> <button @click="{handleClick(e)}"></button>
369-
> ```
366+
Use `$e` for the DOM event object. Bare `e` is not special and resolves like any
367+
other binding path on the current data source.
370368

371369
### Directives
372370

packages/fast-element/DECLARATIVE_RENDERING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ Event bindings such as `@keydown` and `@click` can be represented with hydration
325325

326326
Example event binding:
327327
```html
328-
<button @click="{handleClick(e)}">Button</button>
328+
<button @click="{handleClick($e)}">Button</button>
329329
```
330330

331331
Should result in:

packages/fast-element/MIGRATION.md

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,30 @@ removed `@microsoft/fast-html` package.
4848
2. Update declarative utility imports such as `deepMerge` to
4949
`@microsoft/fast-element/declarative/utilities.js`.
5050
3. Keep importing core FAST Element APIs (for example `FASTElement`, `attr`,
51-
`observable`) from `@microsoft/fast-element`.
51+
`observable`) from `@microsoft/fast-element`.
5252
4. Do not switch to the root `@microsoft/fast-element` barrel for declarative
53-
APIs; the declarative entrypoint owns the debug-message and hydratable-view
54-
side effects.
53+
APIs; the declarative entrypoint owns the debug-message and hydratable-view
54+
side effects.
55+
56+
## Declarative event handler `e` removal (v3)
57+
58+
### Removed behavior
59+
60+
| Removed | Replacement |
61+
|---|---|
62+
| Bare `e` event arguments in declarative event handlers | `$e` |
63+
| `TemplateParser.hasDeprecatedEventSyntax` | No replacement |
64+
65+
Only `$e` and `$c` are reserved event handler arguments in declarative
66+
templates. Bare `e` now resolves like any other binding path on the current
67+
data source.
68+
69+
### Migration steps
70+
71+
1. Replace declarative event bindings such as
72+
`@click="{handleClick(e)}"` with `@click="{handleClick($e)}"`.
73+
2. Remove any `TemplateParser.hasDeprecatedEventSyntax` checks or warnings from
74+
custom tooling.
5575

5676
## Prerendered Content Optimization (v2 → v3)
5777

packages/fast-element/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ TemplateElement.define({ name: "f-template" });
102102
Declarative utilities such as `deepMerge` are available from
103103
`@microsoft/fast-element/declarative/utilities.js`. See
104104
[`DECLARATIVE_HTML.md`](./DECLARATIVE_HTML.md) for declarative usage details.
105+
Declarative event bindings use `$e` for the DOM event object and `$c` for the
106+
execution context.
105107

106108
## Prerendered Content Optimization
107109

packages/fast-element/docs/declarative/api-report.api.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ export class TemplateElement extends FASTElement {
138138
export class TemplateParser {
139139
// Warning: (ae-forgotten-export) The symbol "ViewTemplate" needs to be exported by the entry point declarative.d.ts
140140
createTemplate(strings: Array<string>, values: Array<any>): ViewTemplate<any, any>;
141-
get hasDeprecatedEventSyntax(): boolean;
142141
parse(innerHTML: string, schema: Schema): ResolvedStringsAndValues;
143142
}
144143

packages/fast-element/src/declarative/syntax.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ interface Syntax {
66
clientSideCloseExpression: string;
77
executionContextAccessor: string;
88
eventArgAccessor: string;
9-
deprecatedEventArgAccessor: string;
109
openExpression: string;
1110
closeExpression: string;
1211
unescapedOpenExpression: string;
@@ -26,7 +25,6 @@ export const {
2625
clientSideCloseExpression,
2726
clientSideOpenExpression,
2827
closeExpression,
29-
deprecatedEventArgAccessor,
3028
eventArgAccessor,
3129
executionContextAccessor,
3230
openExpression,
@@ -41,7 +39,6 @@ export const {
4139
clientSideCloseExpression: "}",
4240
clientSideOpenExpression: "{",
4341
closeExpression: "}}",
44-
deprecatedEventArgAccessor: "e",
4542
eventArgAccessor: "$e",
4643
executionContextAccessor: "$c",
4744
openExpression: "{{",

packages/fast-element/src/declarative/template-parser.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -72,37 +72,18 @@ class StringsAccumulator {
7272
*
7373
* This class is intentionally stateless across invocations — all mutable
7474
* parsing state lives on the call stack or in the `TemplateResolutionContext`.
75-
* The only per-parse state is `_hasDeprecatedEventSyntax`, which is reset at
76-
* the start of each `parse()` call.
7775
*
7876
* The parsing pipeline is fully synchronous — no promises are allocated
7977
* during template resolution.
8078
*/
8179
export class TemplateParser {
82-
/**
83-
* Whether the template contains deprecated "e" event argument usage.
84-
* Set during template processing; checked after parsing to emit a
85-
* single warning per template.
86-
*/
87-
// TODO: remove per https://github.com/microsoft/fast/issues/7314
88-
private _hasDeprecatedEventSyntax = false;
89-
90-
/**
91-
* Whether the last parsed template contained deprecated "e" event syntax.
92-
*/
93-
public get hasDeprecatedEventSyntax(): boolean {
94-
return this._hasDeprecatedEventSyntax;
95-
}
96-
9780
/**
9881
* Parse declarative HTML into strings and values for ViewTemplate creation.
9982
* @param innerHTML - The transformed innerHTML to parse.
10083
* @param schema - The Schema instance for property tracking.
10184
* @returns The resolved strings and values.
10285
*/
10386
public parse(innerHTML: string, schema: Schema): ResolvedStringsAndValues {
104-
this._hasDeprecatedEventSyntax = false;
105-
10687
return this.resolveStringsAndValues(null, innerHTML, {
10788
parentContext: null,
10889
level: 0,
@@ -370,14 +351,9 @@ export class TemplateParser {
370351

371352
const parsedArgs = parseEventArgs(argsString);
372353

373-
if (parsedArgs.some(a => a.type === "deprecated-event")) {
374-
this._hasDeprecatedEventSyntax = true;
375-
}
376-
377354
const argResolvers = parsedArgs.map((parsedArg): ((x: any, c: any) => any) => {
378355
switch (parsedArg.type) {
379356
case "event":
380-
case "deprecated-event":
381357
return (_x, c) => c.event;
382358
case "context":
383359
return (_x, c) => c;

0 commit comments

Comments
 (0)