-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGreetElement.js
More file actions
38 lines (30 loc) · 1.17 KB
/
GreetElement.js
File metadata and controls
38 lines (30 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
* A sample custom element that uses some common custom element mixins.
*/
import AttributeMarshalling from 'basic-component-mixins/src/AttributeMarshalling';
import ShadowElementReferences from 'basic-component-mixins/src/ShadowElementReferences';
import ShadowTemplate from 'basic-component-mixins/src/ShadowTemplate';
// Define a custom element.
export default class GreetElement extends AttributeMarshalling(
ShadowElementReferences(ShadowTemplate(HTMLElement))
) {
// Define a "punctuation" attribute.
// If a user of this component sets the "punctuation" attribute in markup,
// the AttributeMarshalling mixin will cause this property to be set.
get punctuation() {
// Use a this.$.id reference created by the ShadowElementReferences mixin.
return this.$.punctuation.textContent;
}
set punctuation(value) {
this.$.punctuation.textContent = value;
}
// This template is picked up by the ShadowTemplate mixin.
get template() {
return `
Hello,
<slot></slot><span id="punctuation">.</span>
`;
}
}
// Register the element. This could alternatively be handled by the importer.
document.registerElement('greet-element', GreetElement);