-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnodecg-replicant.js
46 lines (41 loc) · 1.02 KB
/
nodecg-replicant.js
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
39
40
41
42
43
44
45
46
/**
* @customElement
* @polymer
* @appliesMixin Polymer.MutableData
* @appliesMixin Polymer.NodeCGReplicantTargeting
*/
class NodecgReplicant extends Polymer.NodeCGReplicantTargeting(Polymer.MutableData(Polymer.Element)) {
/**
* Fired when the value of the target replicant changes.
* @event change
*/
static get is() {
return 'nodecg-replicant';
}
static get properties() {
return {
value: {
type: Object,
observer: '_exposedValueChanged',
notify: true
}
};
}
_exposedValueChanged(newVal) {
if (!this._ignoreExposedValueObserver && this.replicant) {
this.replicant.value = newVal;
return this.replicant.value;
}
}
_replicantValueChanged(newVal, oldVal, operations) {
this._ignoreExposedValueObserver = true;
this.set('value', newVal);
this._ignoreExposedValueObserver = false;
this.dispatchEvent(new CustomEvent('change', {
detail: {newVal, oldVal, operations},
bubbles: false,
composed: false
}));
}
}
customElements.define('nodecg-replicant', NodecgReplicant);