Specs: Simplify the platform by only having one shadow tree per element.
R=esprehn@chromium.org Review URL: https://codereview.chromium.org/694613002
This commit is contained in:
parent
4f47cb9215
commit
bcb841290f
@ -11,11 +11,14 @@ SKY MODULE - radio button and radio button group
|
|||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
module.exports = {};
|
module.exports = {};
|
||||||
module.exports.RadioElement = sky.registerElement('radio', class extends Element {
|
module.exports.RadioElement = sky.registerElement({
|
||||||
|
tagName: 'radio',
|
||||||
|
shadow: true,
|
||||||
|
prototype: class extends Element {
|
||||||
constructor () {
|
constructor () {
|
||||||
super();
|
super();
|
||||||
this.addEventListener('click', (event) => this.checked = true);
|
this.addEventListener('click', (event) => this.checked = true);
|
||||||
this.addShadowRoot(new sky.ShadowRoot(module.document.findId('radio-shadow').content.cloneNode(true)));
|
this.shadowRoot.appendChild(module.document.findId('radio-shadow').content.cloneNode(true));
|
||||||
}
|
}
|
||||||
get checked () {
|
get checked () {
|
||||||
return this.hasAttribute('checked');
|
return this.hasAttribute('checked');
|
||||||
@ -37,6 +40,7 @@ SKY MODULE - radio button and radio button group
|
|||||||
if (this.parentNode instanceof module.exports.RadioGroupElement)
|
if (this.parentNode instanceof module.exports.RadioGroupElement)
|
||||||
this.parentNode.setChecked(this);
|
this.parentNode.setChecked(this);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -47,10 +51,13 @@ SKY MODULE - radio button and radio button group
|
|||||||
</style>
|
</style>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
module.exports.RadioGroupElement = sky.registerElement('radiogroup', class extends Element {
|
module.exports.RadioGroupElement = sky.registerElement({
|
||||||
|
tagName: 'radiogroup',
|
||||||
|
shadow: true,
|
||||||
|
prototype: class extends Element {
|
||||||
constructor () {
|
constructor () {
|
||||||
super();
|
super();
|
||||||
this.addShadowRoot(new sky.ShadowRoot(module.document.findId('radiogroup-shadow').content.cloneNode(true)));
|
this.shadowRoot.appendChild(module.document.findId('radiogroup-shadow').content.cloneNode(true));
|
||||||
}
|
}
|
||||||
get value () {
|
get value () {
|
||||||
let children = this.getChildNodes();
|
let children = this.getChildNodes();
|
||||||
@ -76,5 +83,6 @@ SKY MODULE - radio button and radio button group
|
|||||||
if (child != radio)
|
if (child != radio)
|
||||||
child.checked = false;
|
child.checked = false;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user