diff --git a/lib/utils/flattened-nodes-observer.html b/lib/utils/flattened-nodes-observer.html index 78f74127c5..0a291ec248 100644 --- a/lib/utils/flattened-nodes-observer.html +++ b/lib/utils/flattened-nodes-observer.html @@ -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 = @@ -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); diff --git a/test/unit/flattened-nodes-observer.html b/test/unit/flattened-nodes-observer.html index 27b0190d24..54cdd22604 100644 --- a/test/unit/flattened-nodes-observer.html +++ b/test/unit/flattened-nodes-observer.html @@ -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(); + }); + });