mirror of
https://github.com/Polymer/polymer.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #3274 from Polymer/deepContains-fix-wrap-call
Remove call to `wrap` in deepContains
This commit is contained in:
commit
3b26f6dff3
@ -49,10 +49,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
return true;
|
||||
}
|
||||
var n = node;
|
||||
// wrap document for SD polyfill
|
||||
var wrappedDocument = wrap(document);
|
||||
var doc = node.ownerDocument;
|
||||
// walk from node to `this` or `document`
|
||||
while (n && n !== wrappedDocument && n !== this.node) {
|
||||
while (n && n !== doc && n !== this.node) {
|
||||
// use logical parentnode, or native ShadowRoot host
|
||||
n = Polymer.dom(n).parentNode || n.host;
|
||||
}
|
||||
@ -194,7 +193,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
p.oMatchesSelector || p.webkitMatchesSelector;
|
||||
|
||||
return DomApi;
|
||||
|
||||
|
||||
})();
|
||||
|
||||
</script>
|
||||
</script>
|
||||
|
@ -15,7 +15,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
WCT.loadSuites([
|
||||
var suites = [
|
||||
'unit/base.html',
|
||||
'unit/micro.html',
|
||||
'unit/unresolved.html',
|
||||
@ -69,7 +69,13 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
'unit/dom-bind.html',
|
||||
'unit/script-after-import-in-head.html',
|
||||
'unit/globals.html'
|
||||
]);
|
||||
];
|
||||
|
||||
if (document.body.createShadowRoot) {
|
||||
var idx = suites.indexOf('unit/polymer-dom-shadow.html');
|
||||
suites.splice(idx, 0, 'unit/polymer-dom-native-shadow.html');
|
||||
}
|
||||
WCT.loadSuites(suites);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
62
test/unit/polymer-dom-native-shadow.html
Normal file
62
test/unit/polymer-dom-native-shadow.html
Normal file
@ -0,0 +1,62 @@
|
||||
<!doctype html>
|
||||
<!--
|
||||
@license
|
||||
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<script src="../../../web-component-tester/browser.js"></script>
|
||||
<script>Polymer = {dom: 'shadow'};</script>
|
||||
<link rel="import" href="../../polymer.html">
|
||||
<link rel="import" href="polymer-dom-elements.html">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<x-test></x-test>
|
||||
|
||||
<div class="accessors">
|
||||
<x-test-no-distribute><div class="child"></div></x-test-no-distribute>
|
||||
<x-project><div class="child"></div></x-project>
|
||||
</div>
|
||||
|
||||
<x-test-no-distribute id="noDistribute">
|
||||
<div class="bar">Bar</div>
|
||||
<div class="foo">Foo</div>
|
||||
</x-test-no-distribute>
|
||||
|
||||
<x-select1>
|
||||
<div class="select-child"></div>
|
||||
</x-select1>
|
||||
|
||||
<x-select-class1>
|
||||
<div></div>
|
||||
</x-select-class1>
|
||||
|
||||
<x-select-attr>
|
||||
<x-attr></x-attr>
|
||||
</x-select-attr>
|
||||
|
||||
<x-compose-select-attr></x-compose-select-attr>
|
||||
|
||||
<x-redistribute-a-b></x-redistribute-a-b>
|
||||
|
||||
<div id="container">
|
||||
<x-echo></x-echo>
|
||||
<span>1</span>
|
||||
<span>2</span>
|
||||
</div>
|
||||
|
||||
<x-deep-contains></x-deep-contains>
|
||||
|
||||
<x-wrapped></x-wrapped>
|
||||
|
||||
<script src="polymer-dom.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,10 +1,11 @@
|
||||
suite('Polymer.dom', function() {
|
||||
|
||||
var testElement;
|
||||
var wrap = window.wrap || function(n){ return n; };
|
||||
|
||||
suiteSetup(function() {
|
||||
testElement = document.querySelector('x-test');
|
||||
})
|
||||
});
|
||||
|
||||
test('querySelector (local)', function() {
|
||||
var projected = Polymer.dom(testElement.root).querySelector('#projected');
|
||||
@ -96,17 +97,17 @@ suite('Polymer.dom', function() {
|
||||
testElement.distributeContent();
|
||||
Polymer.dom.flush();
|
||||
assert.deepEqual(Polymer.dom(projected).getDestinationInsertionPoints(), ip$);
|
||||
var rere = Polymer.dom(testElement.root).querySelector('x-rereproject');
|
||||
rere = Polymer.dom(testElement.root).querySelector('x-rereproject');
|
||||
assert.equal(rere.is, 'x-rereproject');
|
||||
rere.distributeContent();
|
||||
Polymer.dom.flush();
|
||||
assert.deepEqual(Polymer.dom(projected).getDestinationInsertionPoints(), ip$);
|
||||
var re = Polymer.dom(rere.root).querySelector('x-reproject');
|
||||
re = Polymer.dom(rere.root).querySelector('x-reproject');
|
||||
assert.equal(re.is, 'x-reproject');
|
||||
re.distributeContent();
|
||||
Polymer.dom.flush();
|
||||
assert.deepEqual(Polymer.dom(projected).getDestinationInsertionPoints(), ip$);
|
||||
var p = Polymer.dom(re.root).querySelector('x-project');
|
||||
p = Polymer.dom(re.root).querySelector('x-project');
|
||||
assert.equal(p.is, 'x-project');
|
||||
});
|
||||
|
||||
@ -293,10 +294,10 @@ suite('Polymer.dom', function() {
|
||||
assert.equal(Polymer.dom(c).getDestinationInsertionPoints()[0], ip$[1], 'child not distributed based on host attribute');
|
||||
c.foo = true;
|
||||
Polymer.dom.flush();
|
||||
assert.equal(Polymer.dom(c).getDestinationInsertionPoints()[0], ip$[0], 'child not distributed based on reflecting attribute')
|
||||
assert.equal(Polymer.dom(c).getDestinationInsertionPoints()[0], ip$[0], 'child not distributed based on reflecting attribute');
|
||||
c.foo = false;
|
||||
Polymer.dom.flush();
|
||||
assert.equal(Polymer.dom(c).getDestinationInsertionPoints()[0], ip$[1], 'child not distributed based on reflecting attribute')
|
||||
assert.equal(Polymer.dom(c).getDestinationInsertionPoints()[0], ip$[1], 'child not distributed based on reflecting attribute');
|
||||
});
|
||||
|
||||
test('within a host setting hostAttributes/reflecting properties provokes distribution', function() {
|
||||
@ -312,10 +313,10 @@ suite('Polymer.dom', function() {
|
||||
assert.equal(Polymer.dom(c1).getDestinationInsertionPoints()[0], ip$[1], 'child not distributed based on host attribute');
|
||||
c1.foo = true;
|
||||
Polymer.dom.flush();
|
||||
assert.equal(Polymer.dom(c1).getDestinationInsertionPoints()[0], ip$[0], 'child not distributed based on reflecting attribute')
|
||||
assert.equal(Polymer.dom(c1).getDestinationInsertionPoints()[0], ip$[0], 'child not distributed based on reflecting attribute');
|
||||
c1.foo = false;
|
||||
Polymer.dom.flush();
|
||||
assert.equal(Polymer.dom(c1).getDestinationInsertionPoints()[0], ip$[1], 'child not distributed based on reflecting attribute')
|
||||
assert.equal(Polymer.dom(c1).getDestinationInsertionPoints()[0], ip$[1], 'child not distributed based on reflecting attribute');
|
||||
var c2 = e.$.attr2;
|
||||
Polymer.dom.flush();
|
||||
assert.equal(Polymer.dom(c2).getDestinationInsertionPoints()[0], ip$[0], 'child not distributed based on default value');
|
||||
@ -404,7 +405,7 @@ suite('Polymer.dom', function() {
|
||||
Polymer.dom(rere.root).appendChild(fragment);
|
||||
var added = Polymer.dom(rere.root).querySelectorAll('span');
|
||||
assert.equal(added.length, childCount);
|
||||
for (var i=0; i < added.length; i++) {
|
||||
for (i=0; i < added.length; i++) {
|
||||
Polymer.dom(rere.root).removeChild(added[i]);
|
||||
}
|
||||
assert.equal(Polymer.dom(rere.root).querySelectorAll('span').length, 0);
|
||||
@ -426,7 +427,7 @@ suite('Polymer.dom', function() {
|
||||
var added = Polymer.dom(rere.root).querySelectorAll('span');
|
||||
assert.equal(added.length, childCount+1);
|
||||
assert.equal(added[added.length-1], l);
|
||||
for (var i=0; i < added.length; i++) {
|
||||
for (i=0; i < added.length; i++) {
|
||||
Polymer.dom(rere.root).removeChild(added[i]);
|
||||
}
|
||||
assert.equal(Polymer.dom(rere.root).querySelectorAll('span').length, 0);
|
||||
@ -694,7 +695,7 @@ suite('Polymer.dom accessors', function() {
|
||||
|
||||
test('Polymer.dom node accessors (no distribute)', function() {
|
||||
var child = Polymer.dom(noDistribute).children[0];
|
||||
assert.isTrue(child.classList.contains('child'), 'test node could not be found')
|
||||
assert.isTrue(child.classList.contains('child'), 'test node could not be found');
|
||||
var before = document.createElement('div');
|
||||
var after = document.createElement('div');
|
||||
Polymer.dom(noDistribute).insertBefore(before, child);
|
||||
@ -709,7 +710,7 @@ suite('Polymer.dom accessors', function() {
|
||||
|
||||
test('Polymer.dom node accessors (distribute)', function() {
|
||||
var child = Polymer.dom(distribute).children[0];
|
||||
assert.isTrue(child.classList.contains('child'), 'test node could not be found')
|
||||
assert.isTrue(child.classList.contains('child'), 'test node could not be found');
|
||||
var before = document.createElement('div');
|
||||
var after = document.createElement('div');
|
||||
Polymer.dom(distribute).insertBefore(before, child);
|
||||
|
Loading…
Reference in New Issue
Block a user