OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <script src="../../../resources/js-test.js"></script> | 2 <script src="../../../resources/js-test.js"></script> |
3 <script src="resources/shadow-dom.js"></script> | 3 <script src="resources/shadow-dom.js"></script> |
4 <!-- Adapted from http://jsbin.com/dexinu/6/edit for layout test --> | 4 <!-- Adapted from http://jsbin.com/dexinu/6/edit for layout test --> |
5 | 5 |
6 <template id="XMenuTemplate"> | 6 <template id="XMenuTemplate"> |
7 <style> | 7 <style> |
8 :host { | 8 :host { |
9 display: inline-block; | 9 display: inline-block; |
10 position: relative; | 10 position: relative; |
(...skipping 27 matching lines...) Expand all Loading... |
38 <x-menu id="XMenu4" tabindex="0" delegatesFocus></x-menu> | 38 <x-menu id="XMenu4" tabindex="0" delegatesFocus></x-menu> |
39 </section> | 39 </section> |
40 | 40 |
41 <script> | 41 <script> |
42 function RegisterXMenu() { | 42 function RegisterXMenu() { |
43 var template = document.getElementById('XMenuTemplate'); | 43 var template = document.getElementById('XMenuTemplate'); |
44 | 44 |
45 var xMenuProto = Object.create(HTMLElement.prototype); | 45 var xMenuProto = Object.create(HTMLElement.prototype); |
46 xMenuProto.createdCallback = function() { | 46 xMenuProto.createdCallback = function() { |
47 var delegatesFocus = this.hasAttribute('delegatesFocus'); | 47 var delegatesFocus = this.hasAttribute('delegatesFocus'); |
48 this.createShadowRoot({ 'delegatesFocus': delegatesFocus }) | 48 this.attachShadow({ 'delegatesFocus': delegatesFocus }) |
49 .appendChild( | 49 .appendChild( |
50 document.importNode(template.content, true) | 50 document.importNode(template.content, true) |
51 ); | 51 ); |
52 }; | 52 }; |
53 document.registerElement('x-menu', { | 53 document.registerElement('x-menu', { |
54 prototype: xMenuProto | 54 prototype: xMenuProto |
55 }); | 55 }); |
56 } | 56 } |
57 | 57 |
58 function test() { | 58 function test() { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 shouldBeEqualToString('document.activeElement.id', 'XMenu1'); | 120 shouldBeEqualToString('document.activeElement.id', 'XMenu1'); |
121 backgroundColorShouldBe('XMenu1', 'rgb(170, 170, 170)'); | 121 backgroundColorShouldBe('XMenu1', 'rgb(170, 170, 170)'); |
122 backgroundColorShouldBe('XMenu2', 'rgb(170, 170, 170)'); | 122 backgroundColorShouldBe('XMenu2', 'rgb(170, 170, 170)'); |
123 backgroundColorShouldBe('XMenu3', 'rgb(170, 170, 170)'); | 123 backgroundColorShouldBe('XMenu3', 'rgb(170, 170, 170)'); |
124 backgroundColorShouldBe('XMenu4', 'rgb(170, 170, 170)'); | 124 backgroundColorShouldBe('XMenu4', 'rgb(170, 170, 170)'); |
125 } | 125 } |
126 | 126 |
127 RegisterXMenu(); | 127 RegisterXMenu(); |
128 test(); | 128 test(); |
129 </script> | 129 </script> |
OLD | NEW |