Skip to content

Commit

Permalink
Make event notification handler read the value from currentTarget, (#…
Browse files Browse the repository at this point in the history
…5313)

instead of target which may not be bound to any data.

Fixes #5308
  • Loading branch information
tomalec authored and TimvdLippe committed Aug 2, 2018
1 parent 0bf1e60 commit db2f3cc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/mixins/property-effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]) {
Expand Down
10 changes: 10 additions & 0 deletions test/unit/property-effects.html
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit db2f3cc

Please sign in to comment.