Skip to content

Commit

Permalink
isLightDescendant should return false for self
Browse files Browse the repository at this point in the history
  • Loading branch information
notwaldorf committed Oct 22, 2015
1 parent ce2c2ce commit a0debf4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/standard/utils.html
Expand Up @@ -106,7 +106,7 @@

/**
* 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.
*
Expand All @@ -119,8 +119,8 @@

/**
* 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
Expand All @@ -134,7 +134,7 @@
},

/**
* 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>.
*
Expand Down Expand Up @@ -373,7 +373,7 @@
* @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();
},

Expand Down
12 changes: 10 additions & 2 deletions test/unit/utils-content.html
Expand Up @@ -59,7 +59,7 @@
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');
Expand Down Expand Up @@ -123,7 +123,7 @@
var text = elt7.$.content.getEffectiveTextContent();
assert.equal(text.replace(/\s/g, ''), 'abcde');
});

});

suite('isLight/Local descendant utils', function() {
Expand All @@ -132,6 +132,14 @@
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');
Expand Down

0 comments on commit a0debf4

Please sign in to comment.