diff --git a/src/lib/template/dom-bind.html b/src/lib/template/dom-bind.html index d710c98a31..abacc1c3c6 100644 --- a/src/lib/template/dom-bind.html +++ b/src/lib/template/dom-bind.html @@ -61,6 +61,19 @@ is: 'dom-bind', + properties: { + + /** + * When the global `Polymer.Settings.suppressDomChange` setting is used, + * setting `notifyDomChange: true` will enable firing `dom-change` events + * on this element. + */ + notifyDomChange: { + type: Boolean + } + + }, + extends: 'template', _template: null, @@ -168,7 +181,7 @@ this._children = Polymer.TreeApi.arrayCopyChildNodes(this.root); } this._insertChildren(); - if (!Polymer.Settings.suppressTemplateNotifications) { + if (!Polymer.Settings.suppressTemplateNotifications || this.notifyDomChange) { this.fire('dom-change'); } } diff --git a/test/unit/dom-bind.html b/test/unit/dom-bind.html index bc0e58f2fa..21055ae082 100644 --- a/test/unit/dom-bind.html +++ b/test/unit/dom-bind.html @@ -223,6 +223,35 @@ }); + suite('dom-change', function() { + + test('dom-change when stamped', function(done) { + var bind = document.createElement('template', 'dom-bind'); + var changed = sinon.spy(); + bind.addEventListener('dom-change', changed); + document.body.appendChild(bind); + setTimeout(function() { + assert.equal(changed.callCount, + Polymer.Settings.suppressTemplateNotifications ? 0 : 1); + done(); + }); + }); + + test('re-enable dom-change', function(done) { + if (Polymer.Settings.suppressTemplateNotifications) { + var bind = document.createElement('template', 'dom-bind'); + bind.notifyDomChange = true; + var changed = sinon.spy(); + bind.addEventListener('dom-change', changed); + document.body.appendChild(bind); + setTimeout(function() { + assert.equal(changed.callCount, 1); + done(); + }); + } + }); + + }); diff --git a/test/unit/dom-if.html b/test/unit/dom-if.html index 1bebba63eb..39dfcfbf14 100644 --- a/test/unit/dom-if.html +++ b/test/unit/dom-if.html @@ -699,14 +699,12 @@ test('re-enable dom-change', function() { if (Polymer.Settings.suppressTemplateNotifications) { - test('enable dom-change on instance', function() { - unconfigured1.$['if-1'].setAttribute('notify-dom-change', ''); - unconfigured1.domUpdateHandlerCount = 0; - unconfigured1.shouldStamp = false; - setTimeout(function() { - assert.equal(unconfigured1.domUpdateHandlerCount, 1); - }); - }); + unconfigured1.$['if-1'].setAttribute('notify-dom-change', ''); + unconfigured1.domUpdateHandlerCount = 0; + unconfigured1.shouldStamp = false; + setTimeout(function() { + assert.equal(unconfigured1.domUpdateHandlerCount, 1); + }); } }); diff --git a/test/unit/dom-repeat.html b/test/unit/dom-repeat.html index 46eefa5e4c..97edd6b01f 100644 --- a/test/unit/dom-repeat.html +++ b/test/unit/dom-repeat.html @@ -3874,14 +3874,12 @@

x-repeat-chunked

test('re-enable dom-change', function() { if (Polymer.Settings.suppressTemplateNotifications) { - test('enable dom-change on instance', function() { - unconfigured1.$.repeater.setAttribute('notify-dom-change', ''); - unconfigured1.domUpdateHandlerCount = 0; - unconfigured.items = unconfigured.items.slice(); - setTimeout(function() { - assert.equal(unconfigured1.domUpdateHandlerCount, 1); - }); - }); + unconfigured1.$.repeater.setAttribute('notify-dom-change', ''); + unconfigured1.domUpdateHandlerCount = 0; + unconfigured.items = unconfigured.items.slice(); + setTimeout(function() { + assert.equal(unconfigured1.domUpdateHandlerCount, 1); + }); } });