diff --git a/iron-selectable.html b/iron-selectable.html index 25cfe91..b70a952 100644 --- a/iron-selectable.html +++ b/iron-selectable.html @@ -151,6 +151,10 @@ } }, + listeners: { + 'dom-change': '_onDomChange' + }, + observers: [ '_updateAttrForSelected(attrForSelected)', '_updateSelected(selected)', @@ -346,19 +350,32 @@ // observe items change under the given node. _observeItems: function(node) { - return Polymer.dom(node).observeNodes(function(mutation) { - this._updateItems(); - - if (this._shouldUpdateSelection) { - this._updateSelected(); - } + return Polymer.dom(node).observeNodes(this._onChildlistMutation.bind(this)); + }, - // Let other interested parties know about the change so that - // we don't have to recreate mutation observers everywhere. - this.fire('iron-items-changed', mutation, { - bubbles: false, - cancelable: false + _onDomChange: function(event) { + var localTarget = Polymer.dom(event).localTarget; + if (localTarget.parentNode === this) { + this._onChildlistMutation({ + target: this, + addedNodes: [], + removedNodes: [], }); + } + }, + + _onChildlistMutation: function(mutation) { + this._updateItems(); + + if (this._shouldUpdateSelection) { + this._updateSelected(); + } + + // Let other interested parties know about the change so that + // we don't have to recreate mutation observers everywhere. + this.fire('iron-items-changed', mutation, { + bubbles: false, + cancelable: false }); }, diff --git a/test/template-repeat.html b/test/template-repeat.html index b1ab6a6..f595bc4 100644 --- a/test/template-repeat.html +++ b/test/template-repeat.html @@ -31,7 +31,7 @@