Skip to content

Commit db2f3cc

Browse files
tomalecTimvdLippe
authored andcommitted
Make event notification handler read the value from currentTarget, (#5313)
instead of target which may not be bound to any data. Fixes #5308
1 parent 0bf1e60 commit db2f3cc

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

lib/mixins/property-effects.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ function handleNotification(event, inst, fromProp, toPath, negate) {
353353
toPath = translate(fromProp, toPath, fromPath);
354354
value = detail && detail.value;
355355
} else {
356-
value = event.target[fromProp];
356+
value = event.currentTarget[fromProp];
357357
}
358358
value = negate ? !value : value;
359359
if (!inst[TYPES.READ_ONLY] || !inst[TYPES.READ_ONLY][toPath]) {

test/unit/property-effects.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,16 @@
341341
assert.equal(el.customEventObject.value, 84, 'custom bound path incorrect');
342342
assert.equal(el.observerCounts.customEventObjectValueChanged, 1, 'custom bound path observer not called');
343343
});
344+
345+
test('custom notification bubbling event to property', function() {
346+
const child = document.createElement('div');
347+
el.$.boundChild.appendChild(child);
348+
349+
el.$.boundChild.customEventValue = 42;
350+
child.dispatchEvent(new Event('custom', {bubbles: true}));
351+
assert.equal(el.customEventValue, 42, 'custom bound property incorrect');
352+
assert.equal(el.observerCounts.customEventValueChanged, 1, 'custom bound property observer not called');
353+
});
344354

345355
test('computed property with negative number', function() {
346356
assert.equal(el.$.boundChild.computedNegativeNumber, -1);

0 commit comments

Comments
 (0)