| OLD | NEW |
| (Empty) | |
| 1 <!DOCTYPE html> |
| 2 <body> |
| 3 |
| 4 <form> |
| 5 <input type="checkbox" name="foo" id="cb1" value="Shadow"> |
| 6 <input type="submit"> |
| 7 </form> |
| 8 |
| 9 <style> |
| 10 #cb1 { |
| 11 -webkit-appearance: none; |
| 12 border: outset; |
| 13 padding: 2px; |
| 14 font-family: monospace; |
| 15 font-size: 20px; |
| 16 white-space: pre; |
| 17 width: 30px; |
| 18 height: 30px; |
| 19 margin: 0; |
| 20 } |
| 21 |
| 22 #cb1:focus { |
| 23 outline: none; |
| 24 } |
| 25 </style> |
| 26 <script> |
| 27 cb1.updateAppearance_ = function() { |
| 28 if (this.checked) |
| 29 this.root_.innerHTML = '<span style="color:red;">✔</span>'; |
| 30 else |
| 31 this.root_.innerHTML = '<span> </span>'; |
| 32 }; |
| 33 |
| 34 cb1.init = function() { |
| 35 this.root_ = this.createShadowRoot(); |
| 36 this.checked_ = this.hasAttribute('checked'); |
| 37 this.updateAppearance_(); |
| 38 |
| 39 this.addEventListener('DOMActivate', function() { |
| 40 this.checked = !cb1.checked; |
| 41 this.dispatchEvent(new CustomEvent('change', true, false)); |
| 42 }, false); |
| 43 |
| 44 this.__defineSetter__('checked', function(value) { |
| 45 this.checked_ = !!value; |
| 46 this.updateAppearance_(); |
| 47 // FIXME: We'd like to update HTMLInputElement.prototype.checked, but it |
| 48 // seems there are no ways to do it. Updating 'checked' HTML attribute |
| 49 // (the default value) works for form submission because the checkbox is |
| 50 // never dirty. |
| 51 if (this.checked_) |
| 52 this.setAttribute('checked', ''); |
| 53 else |
| 54 this.removeAttribute('checked', ''); |
| 55 }); |
| 56 |
| 57 this.__defineGetter__('checked', function() { return this.checked_; }); |
| 58 }; |
| 59 |
| 60 cb1.init(); |
| 61 |
| 62 window.onload = function() { |
| 63 if (!window.eventSender) |
| 64 return; |
| 65 eventSender.mouseMoveTo(cb1.offsetLeft + 10, cb1.offsetTop + 10); |
| 66 eventSender.mouseDown(); |
| 67 eventSender.mouseUp(); |
| 68 }; |
| 69 </script> |
| 70 </body> |
| OLD | NEW |