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

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

Issue 829133003: Specs: custom element constructor argument shouldn't clash with the module-global 'module' identifi… (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 11 months 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 | « sky/examples/htmlish/framework/element.sky ('k') | sky/specs/modules.md » ('j') | 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 3
4 <!-- <radio> --> 4 <!-- <radio> -->
5 <template id="radio-shadow"> 5 <template id="radio-shadow">
6 <style> 6 <style>
7 :host { width: 1em; height: 1em; border: solid; background: white; } 7 :host { width: 1em; height: 1em; border: solid; background: white; }
8 :host[checked] { background: black; } 8 :host[checked] { background: black; }
9 </style> 9 </style>
10 </template> 10 </template>
11 <script> 11 <script>
12 module.exports.RadioElement = module.registerElement( 12 module.exports.RadioElement = module.registerElement(
13 class extends Element { 13 class extends Element {
14 static get tagName() { return 'radio'; } 14 static get tagName() { return 'radio'; }
15 static get shadow() { return true; } 15 static get shadow() { return true; }
16 constructor (module) { 16 constructor (hostModule) {
17 super(module); 17 super(hostModule);
18 this.addEventListener('click', (event) => this.checked = true); 18 this.addEventListener('click', (event) => this.checked = true);
19 this.shadowRoot.append(module.document.findId('radio-shadow').content.clo neNode(true)); 19 this.shadowRoot.append(module.document.findId('radio-shadow').content.clo neNode(true));
20 } 20 }
21 get checked () { 21 get checked () {
22 return this.hasAttribute('checked'); 22 return this.hasAttribute('checked');
23 } 23 }
24 set checked (value) { 24 set checked (value) {
25 if (value) 25 if (value)
26 this.setAttribute('checked', ''); 26 this.setAttribute('checked', '');
27 else 27 else
(...skipping 18 matching lines...) Expand all
46 <template id="radiogroup-shadow"> 46 <template id="radiogroup-shadow">
47 <style> 47 <style>
48 :host { padding: 1em; border: thin solid; } 48 :host { padding: 1em; border: thin solid; }
49 </style> 49 </style>
50 </template> 50 </template>
51 <script> 51 <script>
52 module.exports.RadioGroupElement = module.registerElement( 52 module.exports.RadioGroupElement = module.registerElement(
53 class extends Element { 53 class extends Element {
54 static get tagName() { return 'radiogroup'; } 54 static get tagName() { return 'radiogroup'; }
55 static get shadow() { return true; } 55 static get shadow() { return true; }
56 constructor (module) { 56 constructor (hostModule) {
57 super(module); 57 super(hostModule);
58 this.shadowRoot.append(module.document.findId('radiogroup-shadow').conten t.cloneNode(true)); 58 this.shadowRoot.append(module.document.findId('radiogroup-shadow').conten t.cloneNode(true));
59 } 59 }
60 get value () { 60 get value () {
61 let children = this.getChildNodes(); 61 let children = this.getChildNodes();
62 for (let child of children) 62 for (let child of children)
63 if (child instanceof module.exports.RadioElement) 63 if (child instanceof module.exports.RadioElement)
64 if (child.checked) 64 if (child.checked)
65 return child.name; 65 return child.name;
66 return ''; 66 return '';
67 } 67 }
68 set value (name) { 68 set value (name) {
69 let children = this.getChildNodes(); 69 let children = this.getChildNodes();
70 for (let child of children) 70 for (let child of children)
71 if (child instanceof module.exports.RadioElement) 71 if (child instanceof module.exports.RadioElement)
72 if (child.value == name) 72 if (child.value == name)
73 child.checked = true; 73 child.checked = true;
74 } 74 }
75 setChecked(radio) { 75 setChecked(radio) {
76 if (!((radio instanceof module.exports.Radio) && radio.parentNode == this )) 76 if (!((radio instanceof module.exports.Radio) && radio.parentNode == this ))
77 throw; 77 throw;
78 let children = this.getChildNodes(); 78 let children = this.getChildNodes();
79 for (let child of children) 79 for (let child of children)
80 if (child instanceof module.exports.RadioElement) 80 if (child instanceof module.exports.RadioElement)
81 if (child != radio) 81 if (child != radio)
82 child.checked = false; 82 child.checked = false;
83 } 83 }
84 } 84 }
85 ); 85 );
86 </script> 86 </script>
OLDNEW
« no previous file with comments | « sky/examples/htmlish/framework/element.sky ('k') | sky/specs/modules.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698