Skip to content

Commit a0debf4

Browse files
committed
isLightDescendant should return false for self
1 parent ce2c2ce commit a0debf4

2 files changed

Lines changed: 15 additions & 7 deletions

File tree

‎src/standard/utils.html‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106

107107
/**
108108
* Returns a list of nodes that are the effective childNodes. The effective
109-
* childNodes list is the same as the element's childNodes except that
109+
* childNodes list is the same as the element's childNodes except that
110110
* any `<content>` elements are replaced with the list of nodes distributed
111111
* to the `<content>`, the result of its `getDistributedNodes` method.
112112
*
@@ -119,8 +119,8 @@
119119

120120
/**
121121
* Returns a list of elements that are the effective children. The effective
122-
* children list is the same as the element's children except that
123-
* any `<content>` elements are replaced with the list of elements
122+
* children list is the same as the element's children except that
123+
* any `<content>` elements are replaced with the list of elements
124124
* distributed to the `<content>`.
125125
*
126126
* @method getEffectiveChildren
@@ -134,7 +134,7 @@
134134
},
135135

136136
/**
137-
* Returns a string of text content that is the concatenation of the
137+
* Returns a string of text content that is the concatenation of the
138138
* text content's of the element's effective childNodes (the elements
139139
* returned by <a href="#getEffectiveChildNodes>getEffectiveChildNodes</a>.
140140
*
@@ -373,7 +373,7 @@
373373
* @return {Boolean} true if node is in this element's light DOM tree.
374374
*/
375375
isLightDescendant: function(node) {
376-
return this.contains(node) &&
376+
return this !== node && this.contains(node) &&
377377
Polymer.dom(this).getOwnerRoot() === Polymer.dom(node).getOwnerRoot();
378378
},
379379

‎test/unit/utils-content.html‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
var elt2 = document.querySelector('#elt2');
6060
var elt3 = document.querySelector('#elt3');
6161
var elt4 = document.querySelector('#elt4');
62-
62+
6363
test('getContentChildNodes (empty)', function() {
6464
var nodes = elt1.getContentChildNodes();
6565
assert.equal(nodes.length, 1, 'should have 1 text node');
@@ -123,7 +123,7 @@
123123
var text = elt7.$.content.getEffectiveTextContent();
124124
assert.equal(text.replace(/\s/g, ''), 'abcde');
125125
});
126-
126+
127127
});
128128

129129
suite('isLight/Local descendant utils', function() {
@@ -132,6 +132,14 @@
132132
var elt5 = document.querySelector('#elt5');
133133
var elt6 = document.querySelector('#elt6');
134134

135+
test('isLightDescendant is false for self', function() {
136+
assert.isFalse(elt1.isLightDescendant(elt1));
137+
});
138+
139+
test('isLocalDescendant is false for self', function() {
140+
assert.isFalse(elt1.isLocalDescendant(elt1));
141+
});
142+
135143
test('isLightDescendant is true for light children', function() {
136144
var span = elt4.querySelector('span');
137145
var customElement = elt4.querySelector('x-content');

0 commit comments

Comments
 (0)