Merge pull request #3269 from Polymer/shadow-test-tweaks

Shadow test tweaks
This commit is contained in:
Daniel Freedman 2016-01-05 14:35:30 -08:00
commit 4610007799
5 changed files with 30 additions and 50 deletions

View File

@ -26,28 +26,6 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
return TreeApi.arrayCopy(this.node.querySelectorAll(selector)); return TreeApi.arrayCopy(this.node.querySelectorAll(selector));
}, },
_query: function(matcher, node) {
node = node || this.node;
var list = [];
this._queryElements(node.childNodes, matcher, list);
return list;
},
_queryElements: function(elements, matcher, list) {
for (var i=0, l=elements.length, c; (i<l) && (c=elements[i]); i++) {
if (c.nodeType === Node.ELEMENT_NODE) {
this._queryElement(c, matcher, list);
}
}
},
_queryElement: function(node, matcher, list) {
if (matcher(node)) {
list.push(node);
}
this._queryElements(node.childNodes, matcher, list);
},
getOwnerRoot: function() { getOwnerRoot: function() {
var n = this.node; var n = this.node;
while (n) { while (n) {

View File

@ -354,28 +354,6 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
}, this.node); }, this.node);
}, },
_query: function(matcher, node) {
node = node || this.node;
var list = [];
this._queryElements(TreeApi.Logical.getChildNodes(node), matcher, list);
return list;
},
_queryElements: function(elements, matcher, list) {
for (var i=0, l=elements.length, c; (i<l) && (c=elements[i]); i++) {
if (c.nodeType === Node.ELEMENT_NODE) {
this._queryElement(c, matcher, list);
}
}
},
_queryElement: function(node, matcher, list) {
if (matcher(node)) {
list.push(node);
}
this._queryElements(TreeApi.Logical.getChildNodes(node), matcher, list);
},
getDestinationInsertionPoints: function() { getDestinationInsertionPoints: function() {
return this.node._destinationInsertionPoints || []; return this.node._destinationInsertionPoints || [];
}, },

View File

@ -21,6 +21,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
'use strict'; 'use strict';
var Settings = Polymer.Settings; var Settings = Polymer.Settings;
var TreeApi = Polymer.TreeApi;
var DomApi = function(node) { var DomApi = function(node) {
this.node = needsToWrap ? DomApi.wrap(node) : node; this.node = needsToWrap ? DomApi.wrap(node) : node;
@ -134,6 +135,31 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
if (this.observer) { if (this.observer) {
this.observer.notify(); this.observer.notify();
} }
},
// NOTE: `_query` is used primarily for ShadyDOM's querySelector impl,
// but it's also generally useful to recurse through the element tree
// and is used by Polymer's styling system.
_query: function(matcher, node) {
node = node || this.node;
var list = [];
this._queryElements(TreeApi.Logical.getChildNodes(node), matcher, list);
return list;
},
_queryElements: function(elements, matcher, list) {
for (var i=0, l=elements.length, c; (i<l) && (c=elements[i]); i++) {
if (c.nodeType === Node.ELEMENT_NODE) {
this._queryElement(c, matcher, list);
}
}
},
_queryElement: function(node, matcher, list) {
if (matcher(node)) {
list.push(node);
}
this._queryElements(TreeApi.Logical.getChildNodes(node), matcher, list);
} }
}; };

View File

@ -56,10 +56,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
'unit/styling-remote.html', 'unit/styling-remote.html',
'unit/styling-cross-scope-var.html', 'unit/styling-cross-scope-var.html',
'unit/styling-cross-scope-apply.html', 'unit/styling-cross-scope-apply.html',
// TODO(sorvell): disable until this Chrome bug is addressed: 'unit/styling-cross-scope-var.html?dom=shadow',
// https://code.google.com/p/chromium/issues/detail?id=525280 'unit/styling-cross-scope-apply.html?dom=shadow',
// 'unit/styling-cross-scope-var.html?dom=shadow',
// 'unit/styling-cross-scope-apply.html?dom=shadow',
'unit/styling-cross-scope-unknown-host.html', 'unit/styling-cross-scope-unknown-host.html',
'unit/custom-style.html', 'unit/custom-style.html',
'unit/custom-style.html?dom=shadow', 'unit/custom-style.html?dom=shadow',

View File

@ -155,7 +155,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
<div class="foo"></div> <div class="foo"></div>
<div class="foo--bar style-scope"></div> <div class="foo--bar"></div>
<dom-module id="x-baz"> <dom-module id="x-baz">
<style> <style>
@ -489,7 +489,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
}); });
test('BEM-like CSS selectors under media queries', function() { test('BEM-like CSS selectors under media queries', function() {
assertComputed(document.querySelector('.foo--bar'), '3px'); assertComputed(document.querySelector('.foo--bar'), '20px');
}); });
}); });