-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathElementBase.js
More file actions
28 lines (22 loc) · 895 Bytes
/
ElementBase.js
File metadata and controls
28 lines (22 loc) · 895 Bytes
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
/*
* A sample general-purpose base class for defining custom elements that mixes
* in some common features: template stamping into a shadow root, automatic node
* finding, and marshalling between attributes and properties.
*/
import Composable from './Composable';
import TemplateStamping from './TemplateStamping';
import AutomaticNodeFinding from './AutomaticNodeFinding';
import AttributeMarshalling from './AttributeMarshalling';
export default class ElementBase extends Composable(HTMLElement).compose(
TemplateStamping, // before node finding, so shadow root is populated
AutomaticNodeFinding, // before marshalling, so marshalled properties can use it
AttributeMarshalling
) {
/*
* Debugging utility: logs a message, prefixed by the component's tag.
*/
log(text) {
if (super.log) { super.log(text); }
console.log(`${this.localName}: ${text}`);
}
}