Skip to content

Commit

Permalink
fix(FlattenedNodesObserver): do not fail on node without children
Browse files Browse the repository at this point in the history
  • Loading branch information
limonte committed Dec 19, 2017
1 parent 8196483 commit 09bb6cd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/utils/flattened-nodes-observer.html
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
connect() {
if (isSlot(this._target)) {
this._listenSlots([this._target]);
} else {
} else if (this._target.children) {
this._listenSlots(this._target.children);
if (window.ShadyDOM) {
this._shadyChildrenObserver =
Expand Down Expand Up @@ -159,7 +159,7 @@
disconnect() {
if (isSlot(this._target)) {
this._unlistenSlots([this._target]);
} else {
} else if (this._target.children) {
this._unlistenSlots(this._target.children);
if (window.ShadyDOM && this._shadyChildrenObserver) {
ShadyDOM.unobserveChildren(this._shadyChildrenObserver);
Expand Down
10 changes: 10 additions & 0 deletions test/unit/flattened-nodes-observer.html
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,16 @@
document.body.removeChild(host);
});

test('should not fail on node without children', function() {
var recorded;
var el = document;
var observer = new Polymer.FlattenedNodesObserver(el, function(info) {
recorded = info;
});
assert.equal(recorded, null);
observer.disconnect();
});

});

</script>
Expand Down

0 comments on commit 09bb6cd

Please sign in to comment.