mirror of
https://github.com/Polymer/polymer.git
synced 2025-02-25 18:55:30 -06:00
Add test for Polymer.dom().getOwnerRoot.
This commit is contained in:
@@ -58,24 +58,33 @@
|
||||
</script>
|
||||
|
||||
<dom-module id="x-distribute">
|
||||
<template>
|
||||
<div>
|
||||
<span>Elements without test attribute</span>
|
||||
<div id="notTestContainer" style="color: white; background-color: green; min-height: 1em;">
|
||||
<content id="notTestContent" select=":not([test])"></content>
|
||||
</div>
|
||||
<span>Elements with test attribute</span>
|
||||
<div style="color: white; background-color: red; min-height: 1em;">
|
||||
<div id="testContainer">
|
||||
<content id="testContent" select="[test]"></content>
|
||||
</div>
|
||||
<template>
|
||||
<div>
|
||||
<span>Elements without test attribute</span>
|
||||
<div id="notTestContainer" style="color: white; background-color: green; min-height: 1em;">
|
||||
<content id="notTestContent" select=":not([test])"></content>
|
||||
</div>
|
||||
<span>Elements with test attribute</span>
|
||||
<div style="color: white; background-color: red; min-height: 1em;">
|
||||
<div id="testContainer">
|
||||
<content id="testContent" select="[test]"></content>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</dom-element>
|
||||
|
||||
<script>
|
||||
Polymer({
|
||||
is: "x-distribute"
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
</template>
|
||||
</dom-element>
|
||||
|
||||
<script>
|
||||
Polymer({
|
||||
is: "x-distribute"
|
||||
});
|
||||
</script>
|
||||
|
||||
<dom-module id="x-compose">
|
||||
<template><x-project id="project"></x-project></template>
|
||||
</dom-module>
|
||||
<script>
|
||||
Polymer({
|
||||
is: 'x-compose'
|
||||
});
|
||||
</script>
|
||||
@@ -373,4 +373,18 @@ suite('Polymer.dom non-distributed elements', function() {
|
||||
testWithAttr();
|
||||
});
|
||||
|
||||
});
|
||||
test('getOwnerRoot', function() {
|
||||
var test = document.createElement('div');
|
||||
var c1 = document.createElement('x-compose');
|
||||
var c2 = document.createElement('x-compose');
|
||||
Polymer.dom(c1.$.project).appendChild(test);
|
||||
Polymer.dom.flush();
|
||||
assert.equal(Polymer.dom(test).getOwnerRoot(), c1.root, 'getOwnerRoot incorrect for child added to element in root');
|
||||
Polymer.dom(c2.$.project).appendChild(test);
|
||||
Polymer.dom.flush();
|
||||
assert.equal(Polymer.dom(test).getOwnerRoot(), c2.root, 'getOwnerRoot not correctly reset when element moved to different root');
|
||||
Polymer.dom(c1).appendChild(test);
|
||||
assert.notOk(Polymer.dom(test).getOwnerRoot(), 'getOwnerRoot incorrect for child moved from a root to no root');
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user