|
51 | 51 | <h1>Scoped custom element registries Demo</h1> |
52 | 52 |
|
53 | 53 | <section class="intro"> |
54 | | - <p>This page uses two <code><contoso-button></code> custom elements, which are defined in two separate scoped custom element registries.<br> |
| 54 | + <p>This page uses two <code><my-button></code> custom elements, which are defined in two separate scoped custom element registries.<br> |
55 | 55 | Without scoped registries, the second definition would throw an error. With scoped registries, both coexist peacefully.</p> |
56 | 56 |
|
57 | 57 | <strong>What's happening:</strong> |
58 | 58 |
|
59 | 59 | <ul> |
60 | 60 | <li>Two separate scoped registries are created using <code>new CustomElementRegistry()</code>.</li> |
61 | 61 | <li>Each registry is <em>scoped</em> to a different DOM element via the <code>customElementRegistry</code> option.</li> |
62 | | - <li>Two <code><contoso-button></code> elements are created, one in each DOM element, and using different custom element definitions.</li> |
| 62 | + <li>Two <code><my-button></code> elements are created, one in each DOM element, and using different custom element definitions.</li> |
63 | 63 | <li><strong>No naming conflicts.</strong> The same tag name has completely different behaviors in different scopes.</li> |
64 | 64 | </ul> |
65 | 65 | </section> |
@@ -134,7 +134,7 @@ <h1>Scoped custom element registries Demo</h1> |
134 | 134 | const confettiManager = new CanvasConfettiManager(); |
135 | 135 |
|
136 | 136 | // Custom Element Definition: Fancy Button from Cool Library. |
137 | | - class ContosoComponentLibV1Button extends HTMLElement { |
| 137 | + class MyComponentLibV1Button extends HTMLElement { |
138 | 138 | nbOfConfettis = 10; |
139 | 139 | velocityBase = 3; |
140 | 140 | velocityRandom = 2; |
@@ -172,7 +172,7 @@ <h1>Scoped custom element registries Demo</h1> |
172 | 172 | } |
173 | 173 | } |
174 | 174 | </style> |
175 | | - <button>Contoso button V1</button> |
| 175 | + <button>My button V1</button> |
176 | 176 | `; |
177 | 177 |
|
178 | 178 | const button = this.querySelector('button'); |
@@ -220,7 +220,7 @@ <h1>Scoped custom element registries Demo</h1> |
220 | 220 | } |
221 | 221 |
|
222 | 222 | // Custom Element Definition: Fancy Button from Wave Library. |
223 | | - class ContosoComponentLibraryV2Button extends HTMLElement { |
| 223 | + class MyComponentLibraryV2Button extends HTMLElement { |
224 | 224 | nbOfConfettis = 100; |
225 | 225 | angleVariation = 0.5; |
226 | 226 | velocityBase = 4; |
@@ -264,7 +264,7 @@ <h1>Scoped custom element registries Demo</h1> |
264 | 264 | } |
265 | 265 | } |
266 | 266 | </style> |
267 | | - <button>Contoso button V2 ✨</button> |
| 267 | + <button>My button V2 ✨</button> |
268 | 268 | `; |
269 | 269 |
|
270 | 270 | const button = this.querySelector('button'); |
@@ -339,22 +339,22 @@ <h1>Scoped custom element registries Demo</h1> |
339 | 339 | try { |
340 | 340 | // Create two registries, one for each custom element. |
341 | 341 | const registryForV1 = new CustomElementRegistry(); |
342 | | - registryForV1.define('contoso-button', ContosoComponentLibV1Button); |
| 342 | + registryForV1.define('my-button', MyComponentLibV1Button); |
343 | 343 |
|
344 | 344 | const registryForV2 = new CustomElementRegistry(); |
345 | | - registryForV2.define('contoso-button', ContosoComponentLibraryV2Button); |
| 345 | + registryForV2.define('my-button', MyComponentLibraryV2Button); |
346 | 346 |
|
347 | 347 | // Create instances of the custom elements, specifying the registry to use for each. |
348 | | - const ContosoComponentLibV1ButtonElement = document.createElement('contoso-button', { |
| 348 | + const MyComponentLibV1ButtonElement = document.createElement('my-button', { |
349 | 349 | customElementRegistry: registryForV1 |
350 | 350 | }); |
351 | | - const ContosoComponentLibraryV2ButtonElement = document.createElement('contoso-button', { |
| 351 | + const MyComponentLibraryV2ButtonElement = document.createElement('my-button', { |
352 | 352 | customElementRegistry: registryForV2 |
353 | 353 | }); |
354 | 354 |
|
355 | 355 | // Append the elements to the DOM. |
356 | | - document.getElementById('cool-button-container').appendChild(ContosoComponentLibV1ButtonElement); |
357 | | - document.getElementById('wave-button-container').appendChild(ContosoComponentLibraryV2ButtonElement); |
| 356 | + document.getElementById('cool-button-container').appendChild(MyComponentLibV1ButtonElement); |
| 357 | + document.getElementById('wave-button-container').appendChild(MyComponentLibraryV2ButtonElement); |
358 | 358 | } catch (error) { |
359 | 359 | const message = "Your browser doesn't support scoped custom element registries yet 😢. If you need this feature, add a thumbs up 👍 reaction to <a href='https://github.com/web-platform-dx/developer-signals/issues/364'>this issue</a>."; |
360 | 360 | document.querySelector(".demo").innerHTML = `<p>${message}</p>`; |
|
0 commit comments