Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: sky/examples/radio.sky

Issue 680673002: Enter a description of the change. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 SKY MODULE - radio button and radio button group 1 SKY MODULE - radio button and radio button group
2 <!-- accessibility handling not implemented yet, pending mojo service --> 2 <!-- accessibility handling not implemented yet, pending mojo service -->
3 <import src="sky:core" as="sky"/> 3 <import src="sky:core" as="sky"/>
4 4
5 <!-- <radio> --> 5 <!-- <radio> -->
6 <template id="radio-shadow"> 6 <template id="radio-shadow">
7 <style> 7 <style>
8 :host { width: 1em; height: 1em; border: solid; background: white; } 8 :host { width: 1em; height: 1em; border: solid; background: white; }
9 :host[checked] { background: black; } 9 :host[checked] { background: black; }
10 </style> 10 </style>
11 </template> 11 </template>
12 <script> 12 <script>
13 module.exports = {}; 13 module.exports = {};
14 module.exports.RadioElement = sky.registerElement('radio', class extends Elemen t { 14 module.exports.RadioElement = sky.registerElement('radio', class extends Elemen t {
15 constructor () { 15 constructor () {
16 this.addEventListener('click', (event) => this.checked = true); 16 this.addEventListener('click', (event) => this.checked = true);
17 this.createShadowTree().appendChild(module.document.findId('radio-shadow'). cloneNode(true)); 17 this.createShadowTree().appendChild(module.document.findId('radio-shadow'). content.cloneNode(true));
18 } 18 }
19 get checked () { 19 get checked () {
20 return this.hasAttribute('checked'); 20 return this.hasAttribute('checked');
21 } 21 }
22 set checked (value) { 22 set checked (value) {
23 if (value) 23 if (value)
24 this.setAttribute('checked', ''); 24 this.setAttribute('checked', '');
25 else 25 else
26 this.removeAttribute('checked'); 26 this.removeAttribute('checked');
27 } 27 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 if (!((radio instanceof module.exports.Radio) && radio.parentNode == this)) 69 if (!((radio instanceof module.exports.Radio) && radio.parentNode == this))
70 throw; 70 throw;
71 let children = this.getChildNodes(); 71 let children = this.getChildNodes();
72 for (let child of children) 72 for (let child of children)
73 if (child instanceof module.exports.RadioElement) 73 if (child instanceof module.exports.RadioElement)
74 if (child != radio) 74 if (child != radio)
75 child.checked = false; 75 child.checked = false;
76 } 76 }
77 }); 77 });
78 </script> 78 </script>
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698