isLightDescendant should return false for self

This commit is contained in:
Monica Dinculescu
2015-10-22 14:54:43 -07:00
parent ce2c2ce6c8
commit a0debf4e86
2 changed files with 15 additions and 7 deletions
+5 -5
View File
@@ -106,7 +106,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
/**
* Returns a list of nodes that are the effective childNodes. The effective
* childNodes list is the same as the element's childNodes except that
* childNodes list is the same as the element's childNodes except that
* any `<content>` elements are replaced with the list of nodes distributed
* to the `<content>`, the result of its `getDistributedNodes` method.
*
@@ -119,8 +119,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
/**
* Returns a list of elements that are the effective children. The effective
* children list is the same as the element's children except that
* any `<content>` elements are replaced with the list of elements
* children list is the same as the element's children except that
* any `<content>` elements are replaced with the list of elements
* distributed to the `<content>`.
*
* @method getEffectiveChildren
@@ -134,7 +134,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
},
/**
* Returns a string of text content that is the concatenation of the
* Returns a string of text content that is the concatenation of the
* text content's of the element's effective childNodes (the elements
* returned by <a href="#getEffectiveChildNodes>getEffectiveChildNodes</a>.
*
@@ -373,7 +373,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
* @return {Boolean} true if node is in this element's light DOM tree.
*/
isLightDescendant: function(node) {
return this.contains(node) &&
return this !== node && this.contains(node) &&
Polymer.dom(this).getOwnerRoot() === Polymer.dom(node).getOwnerRoot();
},
+10 -2
View File
@@ -59,7 +59,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
var elt2 = document.querySelector('#elt2');
var elt3 = document.querySelector('#elt3');
var elt4 = document.querySelector('#elt4');
test('getContentChildNodes (empty)', function() {
var nodes = elt1.getContentChildNodes();
assert.equal(nodes.length, 1, 'should have 1 text node');
@@ -123,7 +123,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
var text = elt7.$.content.getEffectiveTextContent();
assert.equal(text.replace(/\s/g, ''), 'abcde');
});
});
suite('isLight/Local descendant utils', function() {
@@ -132,6 +132,14 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
var elt5 = document.querySelector('#elt5');
var elt6 = document.querySelector('#elt6');
test('isLightDescendant is false for self', function() {
assert.isFalse(elt1.isLightDescendant(elt1));
});
test('isLocalDescendant is false for self', function() {
assert.isFalse(elt1.isLocalDescendant(elt1));
});
test('isLightDescendant is true for light children', function() {
var span = elt4.querySelector('span');
var customElement = elt4.querySelector('x-content');