Skip to content

Commit

Permalink
Merge pull request #4988 from limonte/fix/listen-slots
Browse files Browse the repository at this point in the history
FlattenedNodesObserver: do not fail on node without children
  • Loading branch information
dfreedm authored Dec 20, 2017
2 parents ee1d71f + 09bb6cd commit b7bd545
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 @@ -143,7 +143,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 @@ -172,7 +172,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 b7bd545

Please sign in to comment.