From a9f71bd1ef3f87d97aada7ea049343254dbdb5bd Mon Sep 17 00:00:00 2001 From: Kevin Schaaf Date: Wed, 10 Jan 2018 11:34:48 -0800 Subject: [PATCH] Ensure path notifications from templatized instances don't throw. Fixes #3422 --- lib/utils/templatize.html | 9 +++++++++ test/unit/templatize.html | 11 +++++++++++ 2 files changed, 20 insertions(+) diff --git a/lib/utils/templatize.html b/lib/utils/templatize.html index dbd69d4505..d8a2ac296c 100644 --- a/lib/utils/templatize.html +++ b/lib/utils/templatize.html @@ -225,6 +225,15 @@ } return model; } + + /** + * Stub of HTMLElement's `dispatchEvent`, so that effects that may + * dispatch events safely no-op. + * + * @param event {Event} Event to dispatch + */ + dispatchEvent(event) { + } } /** @type {!DataTemplate} */ diff --git a/test/unit/templatize.html b/test/unit/templatize.html index b0cc8af595..7a405c4792 100644 --- a/test/unit/templatize.html +++ b/test/unit/templatize.html @@ -355,6 +355,17 @@ assert.equal(div.textContent, 'text'); }); + test('notifies path data changes', function() { + const template = document.getElementById('standalone').cloneNode(true); + const Template = Polymer.Templatize.templatize(template); + const inst = new Template(); + const div = inst.root.firstElementChild; + inst.setProperties({prop: {foo: true}}); + assert.equal(div.prop.foo, true); + inst.set('prop.foo', false); + assert.equal(div.prop.foo, false); + }); + });