Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/fast-element/docs/declarative/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ sequenceDiagram
participant Hydration as enableHydration().whenHydrated()

App->>Hydration: const hydration = enableHydration() [optional]
App->>FER: await MyElement.define({name:'my-el', template: declarativeTemplate()}, [attributeMap(), observerMap()])
App->>FER: MyElement.define({name:'my-el', template: declarativeTemplate()}, [attributeMap(), observerMap()])
note over FER: definition composed; resolver waits for template

DOM->>FTE: f-template connected to DOM
Expand Down
2 changes: 1 addition & 1 deletion packages/fast-element/docs/declarative/lifecycle.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class MyComponent extends FASTElement {
}

// Register with the declarative template bridge
await MyComponent.define({
MyComponent.define({
name: "my-component",
template: declarativeTemplate(),
});
Expand Down
18 changes: 9 additions & 9 deletions packages/fast-element/docs/migration/fast-element-3.md
Original file line number Diff line number Diff line change
Expand Up @@ -383,17 +383,17 @@ This is a **breaking change** for SSR output format. Any system that produces or

| Removed | Replacement |
|---|---|
| `FASTElement.defineAsync()` | Subclass `define()` calls (now return `Promise<TType>`) |
| `FASTElement.defineAsync()` | Subclass `define()` calls |
| `FASTElement.compose()` and subclass `compose()` calls | Subclass `define()` calls |
| `FASTElementDefinition.composeAsync()` | Subclass `define()` calls |
| `FASTElementDefinition.registerAsync()` | `FASTElementDefinition.register()` (same `Promise<Function>` return type) |

### Changed behavior

- Subclass **`define()`** calls now return `Promise<TType>`. When a concrete
template is provided at definition time, the Promise resolves immediately.
When `template: declarativeTemplate()` is used, the Promise resolves after
the matching `<f-template>` supplies the concrete template.
- Subclass **`define()`** calls return `Promise<TType>` only for code that
explicitly needs to observe registration completion. When
`template: declarativeTemplate()` is used, that Promise resolves after the
matching `<f-template>` supplies the concrete template.
- Subclass compose helpers are no longer part of the public authoring surface; use subclass `define()` for registration.
- **`@customElement` decorator** calls `define()` internally but does not return the Promise (fire-and-forget). For complete definitions with a template, the element is registered via a microtask.

Expand All @@ -409,7 +409,7 @@ This is a **breaking change** for SSR output format. Any system that produces or
});

// After
await MyElement.define({
MyElement.define({
name: "my-element",
template: declarativeTemplate(),
});
Expand All @@ -427,7 +427,7 @@ This is a **breaking change** for SSR output format. Any system that produces or
}).define();

// After
await MyElement.define({
MyElement.define({
name: "my-element",
template,
styles,
Expand All @@ -446,7 +446,7 @@ This is a **breaking change** for SSR output format. Any system that produces or
})).define();

// After
await MyElement.define({
MyElement.define({
name: "my-element",
template,
styles,
Expand All @@ -471,7 +471,7 @@ This is a **breaking change** for SSR output format. Any system that produces or
FASTElementDefinition.compose(MyElement, options).define();

// After
await MyElement.define(options);
MyElement.define(options);
```

## Dynamic stylesheet behaviors (v3)
Expand Down
8 changes: 4 additions & 4 deletions packages/fast-element/docs/migration/fast-html.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ See the [`@microsoft/fast-element` migration guide](./fast-element-3.md#hydratio
### Migration steps

1. Replace `RenderableFASTElement(MyComponent).defineAsync({...})` with
`await MyComponent.define({...})` and use `declarativeTemplate()` for
declarative templates. `declarativeTemplate()` is the waiting behavior: it
resolves the matching `<f-template>` before `define()` completes.
`MyComponent.define({...})` and use `declarativeTemplate()` for declarative
templates. If code explicitly observes the Promise returned by `define()`,
it resolves after the matching `<f-template>` supplies the concrete template.

```typescript
// Before
Expand All @@ -49,7 +49,7 @@ See the [`@microsoft/fast-element` migration guide](./fast-element-3.md#hydratio
});

// After
await MyComponent.define({
MyComponent.define({
name: "my-component",
template: declarativeTemplate(),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,8 @@ offending marker.

`declarativeTemplate()` waits for one connected `<f-template>` whose `name`
matches the element definition. Template-first and definition-first loading both
work, but the custom element definition does not finish until the matching
template is available.
work, but custom element registration completes only after the matching template
is available.

```html
<f-template name="user-card">
Expand All @@ -434,7 +434,7 @@ template is available.
```ts
class UserCard extends FASTElement {}

await UserCard.define({
UserCard.define({
name: "user-card",
template: declarativeTemplate(),
});
Expand Down
Loading
Loading