Skip to content

Commit 09b3376

Browse files
decepulisclaude
andcommitted
docs(site): tighten HTML examples in build-your-own-component guide
- Drop unused `static tagName` from the full skip-intro example (the guide registers via `customElements.define()` directly, so the field is dead code from a userland perspective). - Forward `changed: PropertyValues` to `super.update()` in both the intro skeleton and the full example, matching first-party convention and the actual `ReactiveElement` signature. `PropertyValues` now imports from `@videojs/html` (re-exported via #1472). - Trim the "Place your component" skeleton — drop comments and `customElements.define` line — so it's a minimal anchor for what's required, leaving the full example as the first complete class. Addresses review feedback on #1008. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 54837b7 commit 09b3376

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

site/src/content/docs/how-to/build-your-own-component.mdx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -129,21 +129,16 @@ Your element needs to be inside <DocsLink slug="reference/player-provider">`<vid
129129
Extend `MediaElement` from `@videojs/html` so `PlayerController` can schedule DOM updates when state changes:
130130

131131
```ts
132-
import { MediaElement, PlayerController, playerContext, selectTime } from '@videojs/html';
132+
import { MediaElement, PlayerController, playerContext, selectTime, type PropertyValues } from '@videojs/html';
133133

134-
// Extend MediaElement for reactive updates and lifecycle cleanup
135134
class SkipIntroButtonElement extends MediaElement {
136-
// Subscribe to a feature — calls update() when its state changes
137135
#player = new PlayerController(this, playerContext, selectTime);
138136

139-
update() {
140-
super.update();
141-
// Read state and update the DOM here
137+
update(changed: PropertyValues) {
138+
super.update(changed);
142139
const time = this.#player.value;
143140
}
144141
}
145-
146-
customElements.define('skip-intro-button', SkipIntroButtonElement);
147142
```
148143

149144
</FrameworkCase>
@@ -221,11 +216,16 @@ A "skip intro" button that appears during the first 30 seconds of playback and s
221216
</TabsList>
222217
<TabsPanel client:idle value="ts" initial>
223218
```ts
224-
import { MediaElement, PlayerController, playerContext, selectTime, selectPlayback } from '@videojs/html';
219+
import {
220+
MediaElement,
221+
PlayerController,
222+
playerContext,
223+
selectTime,
224+
selectPlayback,
225+
type PropertyValues,
226+
} from '@videojs/html';
225227

226228
class SkipIntroButtonElement extends MediaElement {
227-
static tagName = 'skip-intro-button';
228-
229229
#time = new PlayerController(this, playerContext, selectTime);
230230
#playback = new PlayerController(this, playerContext, selectPlayback);
231231
#disconnect: AbortController | null = null;
@@ -251,8 +251,8 @@ A "skip intro" button that appears during the first 30 seconds of playback and s
251251
this.#disconnect = null;
252252
}
253253

254-
update() {
255-
super.update();
254+
update(changed: PropertyValues) {
255+
super.update(changed);
256256
const time = this.#time.value;
257257
const playback = this.#playback.value;
258258

0 commit comments

Comments
 (0)