OLD | NEW |
(Empty) | |
| 1 <sky> |
| 2 <import src="../resources/chai.sky" /> |
| 3 <import src="../resources/mocha.sky" /> |
| 4 <script> |
| 5 describe("ownerScope", function() { |
| 6 it("should return null for elements not a child of a scope", function() { |
| 7 var doc = new Document(); |
| 8 var element = doc.createElement("div"); |
| 9 assert.isNull(element.ownerScope); |
| 10 }); |
| 11 it("should return the document for elements in the document scope", function()
{ |
| 12 var doc = new Document(); |
| 13 var element = doc.createElement("div"); |
| 14 doc.appendChild(element); |
| 15 assert.equal(element.ownerScope, element.ownerDocument); |
| 16 assert.equal(element.ownerScope, doc); |
| 17 }); |
| 18 it("should return the shadow root for elements in the shadow root scope", func
tion() { |
| 19 var doc = new Document(); |
| 20 var host = doc.createElement("div"); |
| 21 var child = doc.createElement("div"); |
| 22 var shadowRoot = host.ensureShadowRoot(); |
| 23 shadowRoot.appendChild(child); |
| 24 assert.equal(child.ownerScope, shadowRoot); |
| 25 }); |
| 26 it("should return self for a shadow root or document", function() { |
| 27 var doc = new Document(); |
| 28 var host = doc.createElement("div"); |
| 29 doc.appendChild(host); |
| 30 var shadowRoot = host.ensureShadowRoot(); |
| 31 assert.equal(shadowRoot.ownerScope, shadowRoot); |
| 32 assert.equal(doc.ownerScope, doc); |
| 33 }); |
| 34 it("should dynamically update", function() { |
| 35 var doc = new Document(); |
| 36 var host = doc.createElement("div"); |
| 37 var child = doc.createElement("div"); |
| 38 var shadowRoot = host.ensureShadowRoot(); |
| 39 assert.equal(child.ownerScope, null); |
| 40 shadowRoot.appendChild(child); |
| 41 assert.equal(child.ownerScope, shadowRoot); |
| 42 child.remove(); |
| 43 assert.equal(child.ownerScope, null); |
| 44 }); |
| 45 }); |
| 46 </script> |
| 47 </sky> |
OLD | NEW |