From 86e5a51c22423e1500101519ec259b9ef0fdce8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomek=20Wytr=C4=99bowicz?= Date: Thu, 2 Aug 2018 12:04:53 +0200 Subject: [PATCH] Make event notification handler read the value from currentTarget, instead of target which may not be bound to any data. Fixes https://github.com/Polymer/polymer/issues/5308 --- lib/mixins/property-effects.js | 2 +- test/unit/property-effects.html | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/mixins/property-effects.js b/lib/mixins/property-effects.js index 03c8943fe7..248653f664 100644 --- a/lib/mixins/property-effects.js +++ b/lib/mixins/property-effects.js @@ -353,7 +353,7 @@ function handleNotification(event, inst, fromProp, toPath, negate) { toPath = translate(fromProp, toPath, fromPath); value = detail && detail.value; } else { - value = event.target[fromProp]; + value = event.currentTarget[fromProp]; } value = negate ? !value : value; if (!inst[TYPES.READ_ONLY] || !inst[TYPES.READ_ONLY][toPath]) { diff --git a/test/unit/property-effects.html b/test/unit/property-effects.html index ca6ff7daef..fbafbed8a9 100644 --- a/test/unit/property-effects.html +++ b/test/unit/property-effects.html @@ -341,6 +341,16 @@ assert.equal(el.customEventObject.value, 84, 'custom bound path incorrect'); assert.equal(el.observerCounts.customEventObjectValueChanged, 1, 'custom bound path observer not called'); }); + + test('custom notification bubbling event to property', function() { + const child = document.createElement('div'); + el.$.boundChild.appendChild(child); + + el.$.boundChild.customEventValue = 42; + child.dispatchEvent(new Event('custom', {bubbles: true})); + assert.equal(el.customEventValue, 42, 'custom bound property incorrect'); + assert.equal(el.observerCounts.customEventValueChanged, 1, 'custom bound property observer not called'); + }); test('computed property with negative number', function() { assert.equal(el.$.boundChild.computedNegativeNumber, -1);