Skip to content

Commit d8f4090

Browse files
ngdangtu-vnbsmth
andauthoredJun 24, 2024
fix: Better element ID naming for disambiguation (fixes #74) (#77)
* disambiguate a name in simple-template example * Apply suggestions from code review Co-authored-by: Brian Thomas Smith <brian@smith.berlin> --------- Co-authored-by: Brian Thomas Smith <brian@smith.berlin>
1 parent 712ce27 commit d8f4090

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed
 

‎simple-template/index.html

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@
88
<body>
99
<h1>Simple template</h1>
1010

11-
<template id="my-paragraph">
11+
<template id="custom-paragraph">
1212
<style>
1313
p {
1414
color: white;
1515
background-color: #666;
1616
padding: 5px;
1717
}
1818
</style>
19-
<p><slot name="my-text">My default text</slot></p>
19+
<p>
20+
<slot name="my-text">My default text</slot>
21+
</p>
2022
</template>
2123

2224
<my-paragraph>

‎simple-template/main.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ customElements.define('my-paragraph',
33
constructor() {
44
super();
55

6-
const template = document.getElementById('my-paragraph');
6+
const template = document.getElementById('custom-paragraph');
77
const templateContent = template.content;
88

9-
this.attachShadow({mode: 'open'}).appendChild(
9+
this.attachShadow({ mode: 'open' }).appendChild(
1010
templateContent.cloneNode(true)
1111
);
1212
}

0 commit comments

Comments
 (0)