Fix typo that prevented correct functioning of Polymer.dom under Shadow DOM and add tests to catch.

This commit is contained in:
Steven Orvell 2015-11-05 19:29:10 -08:00
parent f5aec30d3d
commit cdc9fde673
3 changed files with 275 additions and 116 deletions

View File

@ -771,13 +771,13 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
};
var forwardMethod = function(method) {
DomApi.prototype[name] = function() {
return this.node[name].apply(this.node, arguments);
DomApi.prototype[method] = function() {
return this.node[method].apply(this.node, arguments);
}
};
forwardMethods(['cloneNode', 'appendChild', 'insertBefore',
'removeChild', 'replaceChild'])
'removeChild', 'replaceChild']);
DomApi.prototype.querySelectorAll = function(selector) {
return arrayCopy(this.node.querySelectorAll(selector));
@ -868,8 +868,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
};
forwardProperties(['parentNode', 'firstChild', 'lastChild',
'nextSibling', 'previousSibling', 'firstElementChild', 'lastElementChild',
'nextElementSibling', 'previousElementSibling']);
'nextSibling', 'previousSibling', 'firstElementChild',
'lastElementChild', 'nextElementSibling', 'previousElementSibling']);
}

View File

@ -34,6 +34,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
'unit/polymer-dom.html',
'unit/polymer-dom-shadow.html',
'unit/polymer-dom-content.html',
'unit/polymer-dom-content.html?dom=shadow',
'unit/polymer-dom-observeNodes.html',
'unit/polymer-dom-observeNodes.html?dom=shadow',
'unit/bind.html',

View File

@ -248,6 +248,14 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
<script>
var usingShady;
suiteSetup(function() {
// NOTE: these tests are mostly for Shady but running them on Shadow DOM
// ensures Polymer.dom functions correctly under Shadow DOM.
usingShady = !Polymer.Settings.useNativeShadow;
})
suite('appendChild & removeChild of <content>', function() {
test('append div to distributing element', function() {
@ -257,17 +265,23 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
var div = document.createElement('div');
Polymer.dom(dist).appendChild(div);
Polymer.dom.flush();
assert.equal(dist.$.distWrapper.firstElementChild, div);
if (usingShady) {
assert.equal(dist.$.distWrapper.firstElementChild, div);
}
// Append to distributed div
var div2 = document.createElement('div');
Polymer.dom(div).appendChild(div2);
Polymer.dom.flush();
assert.equal(dist.$.distWrapper.firstElementChild, div);
assert.equal(div.firstElementChild, div2);
if (usingShady) {
assert.equal(dist.$.distWrapper.firstElementChild, div);
assert.equal(div.firstElementChild, div2);
}
// Remove
Polymer.dom(dist).removeChild(div);
Polymer.dom.flush();
assert.equal(dist.$.distWrapper.firstElementChild, null);
if (usingShady) {
assert.equal(dist.$.distWrapper.firstElementChild, null);
}
document.body.removeChild(dist);
});
@ -278,19 +292,25 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
var div = document.createElement('div');
Polymer.dom(noDist).appendChild(div);
Polymer.dom.flush();
assert.equal(noDist.firstElementChild, noDist.$.static);
assert.equal(noDist.children.length, 1);
if (usingShady) {
assert.equal(noDist.firstElementChild, noDist.$.static);
assert.equal(noDist.children.length, 1);
}
// Append to distributed div
var div2 = document.createElement('div');
Polymer.dom(div).appendChild(div2);
Polymer.dom.flush();
assert.equal(noDist.firstElementChild, noDist.$.static);
assert.equal(noDist.children.length, 1);
if (usingShady) {
assert.equal(noDist.firstElementChild, noDist.$.static);
assert.equal(noDist.children.length, 1);
}
// Remove
Polymer.dom(noDist).removeChild(div);
Polymer.dom.flush();
assert.equal(noDist.firstElementChild, noDist.$.static);
assert.equal(noDist.children.length, 1);
if (usingShady) {
assert.equal(noDist.firstElementChild, noDist.$.static);
assert.equal(noDist.children.length, 1);
}
document.body.removeChild(noDist);
});
@ -301,17 +321,23 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
var div = document.createElement('div');
Polymer.dom(dist.root).appendChild(div);
Polymer.dom.flush();
assert.equal(dist.$.distWrapper.nextElementSibling, div);
if (usingShady) {
assert.equal(dist.$.distWrapper.nextElementSibling, div);
}
// Append to div in root
var div2 = document.createElement('div');
Polymer.dom(div).appendChild(div2);
Polymer.dom.flush();
assert.equal(dist.$.distWrapper.nextElementSibling, div);
assert.equal(dist.$.distWrapper.nextElementSibling.firstElementChild, div2);
if (usingShady) {
assert.equal(dist.$.distWrapper.nextElementSibling, div);
assert.equal(dist.$.distWrapper.nextElementSibling.firstElementChild, div2);
}
// Remove
Polymer.dom(dist.root).removeChild(div);
Polymer.dom.flush();
assert.equal(dist.$.distWrapper.nextElementSibling, null);
if (usingShady) {
assert.equal(dist.$.distWrapper.nextElementSibling, null);
}
document.body.removeChild(dist);
});
@ -322,17 +348,23 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
var div = document.createElement('div');
Polymer.dom(noDist.root).appendChild(div);
Polymer.dom.flush();
assert.equal(noDist.$.static.nextElementSibling, div);
if (usingShady) {
assert.equal(noDist.$.static.nextElementSibling, div);
}
// Append to div in root
var div2 = document.createElement('div');
Polymer.dom(div).appendChild(div2);
Polymer.dom.flush();
assert.equal(noDist.$.static.nextElementSibling, div);
assert.equal(noDist.$.static.nextElementSibling.firstElementChild, div2);
if (usingShady) {
assert.equal(noDist.$.static.nextElementSibling, div);
assert.equal(noDist.$.static.nextElementSibling.firstElementChild, div2);
}
// Remove
Polymer.dom(noDist.root).removeChild(div);
Polymer.dom.flush();
assert.equal(noDist.$.static.nextElementSibling, null);
if (usingShady) {
assert.equal(noDist.$.static.nextElementSibling, null);
}
document.body.removeChild(noDist);
});
@ -343,17 +375,23 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
var div = document.createElement('div');
Polymer.dom(compose.$.dist).appendChild(div);
Polymer.dom.flush();
assert.equal(compose.$.dist.$.distWrapper.firstElementChild, div);
if (usingShady) {
assert.equal(compose.$.dist.$.distWrapper.firstElementChild, div);
}
// Append to distributed div
var div2 = document.createElement('div');
Polymer.dom(div).appendChild(div2);
Polymer.dom.flush();
assert.equal(compose.$.dist.$.distWrapper.firstElementChild, div);
assert.equal(div.firstElementChild, div2);
if (usingShady) {
assert.equal(compose.$.dist.$.distWrapper.firstElementChild, div);
assert.equal(div.firstElementChild, div2);
}
// Remove
Polymer.dom(compose.$.dist).removeChild(div);
Polymer.dom.flush();
assert.equal(compose.$.dist.$.distWrapper.firstElementChild, null);
if (usingShady) {
assert.equal(compose.$.dist.$.distWrapper.firstElementChild, null);
}
document.body.removeChild(compose);
});
@ -364,19 +402,25 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
var div = document.createElement('div');
Polymer.dom(compose.$.noDist).appendChild(div);
Polymer.dom.flush();
assert.equal(compose.$.noDist.firstElementChild, compose.$.noDist.$.static);
assert.equal(compose.$.noDist.children.length, 1);
if (usingShady) {
assert.equal(compose.$.noDist.firstElementChild, compose.$.noDist.$.static);
assert.equal(compose.$.noDist.children.length, 1);
}
// Append to div in root
var div2 = document.createElement('div');
Polymer.dom(div).appendChild(div2);
Polymer.dom.flush();
assert.equal(compose.$.noDist.firstElementChild, compose.$.noDist.$.static);
assert.equal(compose.$.noDist.children.length, 1);
if (usingShady) {
assert.equal(compose.$.noDist.firstElementChild, compose.$.noDist.$.static);
assert.equal(compose.$.noDist.children.length, 1);
}
// Remove
Polymer.dom(compose.$.noDist).removeChild(div);
Polymer.dom.flush();
assert.equal(compose.$.noDist.firstElementChild, compose.$.noDist.$.static);
assert.equal(compose.$.noDist.children.length, 1);
if (usingShady) {
assert.equal(compose.$.noDist.firstElementChild, compose.$.noDist.$.static);
assert.equal(compose.$.noDist.children.length, 1);
}
document.body.removeChild(compose);
});
@ -393,11 +437,15 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
content.setAttribute('select', '.insert');
Polymer.dom(noDist.root).appendChild(content);
Polymer.dom.flush();
assert.equal(noDist.$.static.nextElementSibling, div);
if (usingShady) {
assert.equal(noDist.$.static.nextElementSibling, div);
}
// Remove
Polymer.dom(noDist.root).removeChild(content);
Polymer.dom.flush();
assert.equal(noDist.$.static.nextElementSibling, null);
if (usingShady) {
assert.equal(noDist.$.static.nextElementSibling, null);
}
document.body.removeChild(noDist);
});
@ -413,11 +461,15 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
div.classList.add('insert');
Polymer.dom(noDist).appendChild(div);
Polymer.dom.flush();
assert.equal(noDist.$.static.nextElementSibling, div);
if (usingShady) {
assert.equal(noDist.$.static.nextElementSibling, div);
}
// Remove
Polymer.dom(noDist.root).removeChild(content);
Polymer.dom.flush();
assert.equal(noDist.$.static.nextElementSibling, null);
if (usingShady) {
assert.equal(noDist.$.static.nextElementSibling, null);
}
document.body.removeChild(noDist);
});
@ -434,11 +486,15 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
content.setAttribute('select', '.insert');
Polymer.dom(noDist.$.static).appendChild(content);
Polymer.dom.flush();
assert.equal(noDist.$.static.firstElementChild, div);
if (usingShady) {
assert.equal(noDist.$.static.firstElementChild, div);
}
// Remove
Polymer.dom(noDist.$.static).removeChild(content);
Polymer.dom.flush();
assert.equal(noDist.$.static.firstElementChild, null);
if (usingShady) {
assert.equal(noDist.$.static.firstElementChild, null);
}
document.body.removeChild(noDist);
});
@ -454,11 +510,15 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
div.classList.add('insert');
Polymer.dom(noDist).appendChild(div);
Polymer.dom.flush();
assert.equal(noDist.$.static.firstElementChild, div);
if (usingShady) {
assert.equal(noDist.$.static.firstElementChild, div);
}
// Remove
Polymer.dom(noDist.$.static).removeChild(content);
Polymer.dom.flush();
assert.equal(noDist.$.static.firstElementChild, null);
if (usingShady) {
assert.equal(noDist.$.static.firstElementChild, null);
}
document.body.removeChild(noDist);
});
@ -477,11 +537,15 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
frag.appendChild(content);
Polymer.dom(noDist.root).appendChild(frag);
Polymer.dom.flush();
assert.equal(noDist.$.static.nextElementSibling, div);
if (usingShady) {
assert.equal(noDist.$.static.nextElementSibling, div);
}
// Remove
Polymer.dom(noDist.root).removeChild(content);
Polymer.dom.flush();
assert.equal(noDist.$.static.firstElementChild, null);
if (usingShady) {
assert.equal(noDist.$.static.firstElementChild, null);
}
document.body.removeChild(noDist);
});
@ -499,11 +563,15 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
div.classList.add('insert');
Polymer.dom(noDist).appendChild(div);
Polymer.dom.flush();
assert.equal(noDist.$.static.nextElementSibling, div);
if (usingShady) {
assert.equal(noDist.$.static.nextElementSibling, div);
}
// Remove
Polymer.dom(noDist.root).removeChild(content);
Polymer.dom.flush();
assert.equal(noDist.$.static.firstElementChild, null);
if (usingShady) {
assert.equal(noDist.$.static.firstElementChild, null);
}
document.body.removeChild(noDist);
});
@ -524,12 +592,16 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
frag.appendChild(wrapper);
Polymer.dom(noDist.root).appendChild(frag);
Polymer.dom.flush();
assert.equal(noDist.$.static.nextElementSibling, wrapper);
assert.equal(wrapper.firstElementChild, div);
if (usingShady) {
assert.equal(noDist.$.static.nextElementSibling, wrapper);
assert.equal(wrapper.firstElementChild, div);
}
// Remove
Polymer.dom(noDist.root).removeChild(wrapper);
Polymer.dom.flush();
assert.equal(noDist.$.static.firstElementChild, null);
if (usingShady) {
assert.equal(noDist.$.static.firstElementChild, null);
}
document.body.removeChild(noDist);
});
@ -549,12 +621,16 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
div.classList.add('insert');
Polymer.dom(noDist).appendChild(div);
Polymer.dom.flush();
assert.equal(noDist.$.static.nextElementSibling, wrapper);
assert.equal(wrapper.firstElementChild, div);
if (usingShady) {
assert.equal(noDist.$.static.nextElementSibling, wrapper);
assert.equal(wrapper.firstElementChild, div);
}
// Remove
Polymer.dom(noDist.root).removeChild(wrapper);
Polymer.dom.flush();
assert.equal(noDist.$.static.firstElementChild, null);
if (usingShady) {
assert.equal(noDist.$.static.firstElementChild, null);
}
document.body.removeChild(noDist);
});
@ -575,12 +651,16 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
frag.appendChild(wrapper);
Polymer.dom(noDist.$.static).appendChild(frag);
Polymer.dom.flush();
assert.equal(noDist.$.static.firstElementChild, wrapper, 'wrong wrapper');
assert.equal(wrapper.firstElementChild, div);
if (usingShady) {
assert.equal(noDist.$.static.firstElementChild, wrapper, 'wrong wrapper');
assert.equal(wrapper.firstElementChild, div);
}
// Remove
Polymer.dom(noDist.$.static).removeChild(wrapper);
Polymer.dom.flush();
assert.equal(noDist.$.static.firstElementChild, null);
if (usingShady) {
assert.equal(noDist.$.static.firstElementChild, null);
}
document.body.removeChild(noDist);
});
@ -600,12 +680,16 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
div.classList.add('insert');
Polymer.dom(noDist).appendChild(div);
Polymer.dom.flush();
assert.equal(noDist.$.static.firstElementChild, wrapper, 'wrong wrapper');
assert.equal(wrapper.firstElementChild, div);
if (usingShady) {
assert.equal(noDist.$.static.firstElementChild, wrapper, 'wrong wrapper');
assert.equal(wrapper.firstElementChild, div);
}
// Remove
Polymer.dom(noDist.$.static).removeChild(wrapper);
Polymer.dom.flush();
assert.equal(noDist.$.static.firstElementChild, null);
if (usingShady) {
assert.equal(noDist.$.static.firstElementChild, null);
}
document.body.removeChild(noDist);
});
@ -622,13 +706,17 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
content.setAttribute('select', '.insert');
Polymer.dom(compose.$.noDist).appendChild(content);
Polymer.dom.flush();
assert.equal(compose.$.noDist.firstElementChild, compose.$.noDist.$.static);
assert.equal(compose.$.noDist.children.length, 1);
if (usingShady) {
assert.equal(compose.$.noDist.firstElementChild, compose.$.noDist.$.static);
assert.equal(compose.$.noDist.children.length, 1);
}
// Remove
Polymer.dom(compose.$.noDist).removeChild(content);
Polymer.dom.flush();
assert.equal(compose.$.noDist.firstElementChild, compose.$.noDist.$.static);
assert.equal(compose.$.noDist.children.length, 1);
if (usingShady) {
assert.equal(compose.$.noDist.firstElementChild, compose.$.noDist.$.static);
assert.equal(compose.$.noDist.children.length, 1);
}
document.body.removeChild(compose);
});
@ -644,13 +732,17 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
div.classList.add('insert');
Polymer.dom(compose).appendChild(div);
Polymer.dom.flush();
assert.equal(compose.$.noDist.firstElementChild, compose.$.noDist.$.static);
assert.equal(compose.$.noDist.children.length, 1);
if (usingShady) {
assert.equal(compose.$.noDist.firstElementChild, compose.$.noDist.$.static);
assert.equal(compose.$.noDist.children.length, 1);
}
// Remove
Polymer.dom(compose.$.noDist).removeChild(content);
Polymer.dom.flush();
assert.equal(compose.$.noDist.firstElementChild, compose.$.noDist.$.static);
assert.equal(compose.$.noDist.children.length, 1);
if (usingShady) {
assert.equal(compose.$.noDist.firstElementChild, compose.$.noDist.$.static);
assert.equal(compose.$.noDist.children.length, 1);
}
document.body.removeChild(compose);
});
@ -671,13 +763,17 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
frag.appendChild(wrapper);
Polymer.dom(compose.$.noDist).appendChild(frag);
Polymer.dom.flush();
assert.equal(compose.$.noDist.firstElementChild, compose.$.noDist.$.static);
assert.equal(compose.$.noDist.children.length, 1);
if (usingShady) {
assert.equal(compose.$.noDist.firstElementChild, compose.$.noDist.$.static);
assert.equal(compose.$.noDist.children.length, 1);
}
// Remove
Polymer.dom(compose.$.noDist).removeChild(wrapper);
Polymer.dom.flush();
assert.equal(compose.$.noDist.firstElementChild, compose.$.noDist.$.static);
assert.equal(compose.$.noDist.children.length, 1);
if (usingShady) {
assert.equal(compose.$.noDist.firstElementChild, compose.$.noDist.$.static);
assert.equal(compose.$.noDist.children.length, 1);
}
document.body.removeChild(compose);
});
@ -697,13 +793,17 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
div.classList.add('insert');
Polymer.dom(compose).appendChild(div);
Polymer.dom.flush();
assert.equal(compose.$.noDist.firstElementChild, compose.$.noDist.$.static);
assert.equal(compose.$.noDist.children.length, 1);
if (usingShady) {
assert.equal(compose.$.noDist.firstElementChild, compose.$.noDist.$.static);
assert.equal(compose.$.noDist.children.length, 1);
}
// Remove
Polymer.dom(compose.$.noDist).removeChild(wrapper);
Polymer.dom.flush();
assert.equal(compose.$.noDist.firstElementChild, compose.$.noDist.$.static);
assert.equal(compose.$.noDist.children.length, 1);
if (usingShady) {
assert.equal(compose.$.noDist.firstElementChild, compose.$.noDist.$.static);
assert.equal(compose.$.noDist.children.length, 1);
}
document.body.removeChild(compose);
});
@ -720,11 +820,15 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
content.setAttribute('select', '.insert');
Polymer.dom(compose.$.dist).appendChild(content);
Polymer.dom.flush();
assert.equal(compose.$.dist.$.distWrapper.firstElementChild, div);
if (usingShady) {
assert.equal(compose.$.dist.$.distWrapper.firstElementChild, div);
}
// Remove
Polymer.dom(compose.$.dist).removeChild(content);
Polymer.dom.flush();
assert.equal(compose.$.dist.$.distWrapper.firstElementChild, null);
if (usingShady) {
assert.equal(compose.$.dist.$.distWrapper.firstElementChild, null);
}
document.body.removeChild(compose);
});
@ -740,11 +844,15 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
div.classList.add('insert');
Polymer.dom(compose).appendChild(div);
Polymer.dom.flush();
assert.equal(compose.$.dist.$.distWrapper.firstElementChild, div);
if (usingShady) {
assert.equal(compose.$.dist.$.distWrapper.firstElementChild, div);
}
// Remove
Polymer.dom(compose.$.dist).removeChild(content);
Polymer.dom.flush();
assert.equal(compose.$.dist.$.distWrapper.firstElementChild, null);
if (usingShady) {
assert.equal(compose.$.dist.$.distWrapper.firstElementChild, null);
}
document.body.removeChild(compose);
});
@ -765,12 +873,16 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
frag.appendChild(wrapper);
Polymer.dom(compose.$.dist).appendChild(frag);
Polymer.dom.flush();
assert.equal(compose.$.dist.$.distWrapper.firstElementChild, wrapper);
assert.equal(wrapper.firstElementChild, div);
if (usingShady) {
assert.equal(compose.$.dist.$.distWrapper.firstElementChild, wrapper);
assert.equal(wrapper.firstElementChild, div);
}
// Remove
Polymer.dom(compose.$.dist).removeChild(wrapper);
Polymer.dom.flush();
assert.equal(compose.$.dist.$.distWrapper.firstElementChild, null);
if (usingShady) {
assert.equal(compose.$.dist.$.distWrapper.firstElementChild, null);
}
document.body.removeChild(compose);
});
@ -790,12 +902,16 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
div.classList.add('insert');
Polymer.dom(compose).appendChild(div);
Polymer.dom.flush();
assert.equal(compose.$.dist.$.distWrapper.firstElementChild, wrapper);
assert.equal(wrapper.firstElementChild, div);
if (usingShady) {
assert.equal(compose.$.dist.$.distWrapper.firstElementChild, wrapper);
assert.equal(wrapper.firstElementChild, div);
}
// Remove
Polymer.dom(compose.$.dist).removeChild(wrapper);
Polymer.dom.flush();
assert.equal(compose.$.dist.$.distWrapper.firstElementChild, null);
if (usingShady) {
assert.equal(compose.$.dist.$.distWrapper.firstElementChild, null);
}
document.body.removeChild(compose);
});
@ -1291,18 +1407,24 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
var div = document.createElement('div');
Polymer.dom(el).appendChild(div);
Polymer.dom.flush();
assert.equal(el.$.dist1.$.distWrapper.firstElementChild, div);
assert.equal(el.$.dist2.$.distWrapper.firstElementChild, null);
if (usingShady) {
assert.equal(el.$.dist1.$.distWrapper.firstElementChild, div);
assert.equal(el.$.dist2.$.distWrapper.firstElementChild, null);
}
// Remove first content
Polymer.dom(el.$.dist1).removeChild(el.$.content1);
Polymer.dom.flush();
assert.equal(el.$.dist1.$.distWrapper.firstElementChild, null);
assert.equal(el.$.dist2.$.distWrapper.firstElementChild, div);
if (usingShady) {
assert.equal(el.$.dist1.$.distWrapper.firstElementChild, null);
assert.equal(el.$.dist2.$.distWrapper.firstElementChild, div);
}
// Re-add a new first content
Polymer.dom(el.$.dist1).appendChild(document.createElement('content'));
Polymer.dom.flush();
assert.equal(el.$.dist1.$.distWrapper.firstElementChild, div);
assert.equal(el.$.dist2.$.distWrapper.firstElementChild, null);
if (usingShady) {
assert.equal(el.$.dist1.$.distWrapper.firstElementChild, div);
assert.equal(el.$.dist2.$.distWrapper.firstElementChild, null);
}
});
test('remove, append first distributing element', function() {
@ -1312,12 +1434,16 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
var div = document.createElement('div');
Polymer.dom(el).appendChild(div);
Polymer.dom.flush();
assert.equal(el.$.dist1.$.distWrapper.firstElementChild, div);
assert.equal(el.$.dist2.$.distWrapper.firstElementChild, null);
if (usingShady) {
assert.equal(el.$.dist1.$.distWrapper.firstElementChild, div);
assert.equal(el.$.dist2.$.distWrapper.firstElementChild, null);
}
// Remove first element with nested content
Polymer.dom(el.root).removeChild(el.$.dist1);
Polymer.dom.flush();
assert.equal(el.$.dist2.$.distWrapper.firstElementChild, div);
if (usingShady) {
assert.equal(el.$.dist2.$.distWrapper.firstElementChild, div);
}
// Re-add a new first content
var frag = document.createDocumentFragment();
var dist = document.createElement('x-dist');
@ -1327,8 +1453,10 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
// Note, special call required here
el.distributeContent(true);
Polymer.dom.flush();
assert.equal(dist.$.distWrapper.firstElementChild, div);
assert.equal(el.$.dist2.$.distWrapper.firstElementChild, null);
if (usingShady) {
assert.equal(dist.$.distWrapper.firstElementChild, div);
assert.equal(el.$.dist2.$.distWrapper.firstElementChild, null);
}
});
test('move first distributing element', function() {
@ -1338,15 +1466,19 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
var div = document.createElement('div');
Polymer.dom(el).appendChild(div);
Polymer.dom.flush();
assert.equal(el.$.dist1.$.distWrapper.firstElementChild, div);
assert.equal(el.$.dist2.$.distWrapper.firstElementChild, null);
if (usingShady) {
assert.equal(el.$.dist1.$.distWrapper.firstElementChild, div);
assert.equal(el.$.dist2.$.distWrapper.firstElementChild, null);
}
// Remove first element with nested content to the end
Polymer.dom(el.root).appendChild(el.$.dist1);
// Note, special call required here
el.distributeContent(true);
Polymer.dom.flush();
assert.equal(el.$.dist1.$.distWrapper.firstElementChild, null);
assert.equal(el.$.dist2.$.distWrapper.firstElementChild, div);
if (usingShady) {
assert.equal(el.$.dist1.$.distWrapper.firstElementChild, null);
assert.equal(el.$.dist2.$.distWrapper.firstElementChild, div);
}
});
});
@ -1359,11 +1491,15 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
var div = document.createElement('div');
div.classList.add('insert');
Polymer.dom(el).appendChild(div);
assert.ok(!el.querySelector('#container .insert'));
if (usingShady) {
assert.ok(!el.querySelector('#container .insert'));
}
el.$.domif.if = true;
el.$.domif.render();
Polymer.dom.flush();
assert.ok(el.querySelector('#container .insert'));
if (usingShady) {
assert.ok(el.querySelector('#container .insert'));
}
document.body.removeChild(el);
});
@ -1373,11 +1509,15 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
var div = document.createElement('div');
div.classList.add('insert');
Polymer.dom(el).appendChild(div);
assert(!el.querySelector('#container .insert'));
if (usingShady) {
assert(!el.querySelector('#container .insert'));
}
el.$.domif.if = true;
el.$.domif.render();
Polymer.dom.flush();
assert.ok(el.querySelector('#container .insert'));
if (usingShady) {
assert.ok(el.querySelector('#container .insert'));
}
document.body.removeChild(el);
});
@ -1387,12 +1527,16 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
var div = document.createElement('div');
div.classList.add('insert');
Polymer.dom(el).appendChild(div);
assert.ok(!el.querySelector('#redistContainer .insert'));
if (usingShady) {
assert.ok(!el.querySelector('#redistContainer .insert'));
}
el.$.redistDomif.if = true;
el.$.redistContainer.$.domif.if = true;
el.$.redistDomif.render();
Polymer.dom.flush();
assert.ok(el.querySelector('#redistContainer .insert'));
if (usingShady) {
assert.ok(el.querySelector('#redistContainer .insert'));
}
document.body.removeChild(el);
});
@ -1402,11 +1546,15 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
var div = document.createElement('div');
div.classList.add('insert');
Polymer.dom(el).appendChild(div);
assert(!el.querySelector('#redistContainer .insert'));
if (usingShady) {
assert(!el.querySelector('#redistContainer .insert'));
}
el.$.redistDomif.if = true;
el.$.redistDomif.render();
Polymer.dom.flush();
assert.ok(el.querySelector('#redistContainer .insert'));
if (usingShady) {
assert.ok(el.querySelector('#redistContainer .insert'));
}
document.body.removeChild(el);
});
@ -1422,32 +1570,42 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
el.$.foo.render();
el.$.notFoo.render();
Polymer.dom.flush();
assert.equal(c1.parentNode, el.$.container1);
assert.equal(c2.parentNode, el.$.container1);
if (usingShady) {
assert.equal(c1.parentNode, el.$.container1);
assert.equal(c2.parentNode, el.$.container1);
}
el.foo = !el.foo;
el.$.foo.render();
el.$.notFoo.render();
Polymer.dom.flush();
assert.equal(c1.parentNode, el.$.container2);
assert.equal(c2.parentNode, el.$.container2);
if (usingShady) {
assert.equal(c1.parentNode, el.$.container2);
assert.equal(c2.parentNode, el.$.container2);
}
el.foo = !el.foo;
el.$.foo.render();
el.$.notFoo.render();
Polymer.dom.flush();
assert.equal(c1.parentNode, el.$.container1);
assert.equal(c2.parentNode, el.$.container1);
if (usingShady) {
assert.equal(c1.parentNode, el.$.container1);
assert.equal(c2.parentNode, el.$.container1);
}
el.foo = !el.foo;
el.$.foo.render();
el.$.notFoo.render();
Polymer.dom.flush();
assert.equal(c1.parentNode, el.$.container2);
assert.equal(c2.parentNode, el.$.container2);
if (usingShady) {
assert.equal(c1.parentNode, el.$.container2);
assert.equal(c2.parentNode, el.$.container2);
}
el.foo = !el.foo;
el.$.foo.render();
el.$.notFoo.render();
Polymer.dom.flush();
assert.equal(c1.parentNode, el.$.container1);
assert.equal(c2.parentNode, el.$.container1);
if (usingShady) {
assert.equal(c1.parentNode, el.$.container1);
assert.equal(c2.parentNode, el.$.container1);
}
document.body.removeChild(el);
});