mirror of
https://github.com/Polymer/polymer.git
synced 2025-02-25 18:55:30 -06:00
Make event notification handler read the value from currentTarget, (#5313)
instead of target which may not be bound to any data. Fixes https://github.com/Polymer/polymer/issues/5308
This commit is contained in:
committed by
Tim van der Lippe
parent
0bf1e60c15
commit
db2f3cc71c
@@ -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]) {
|
||||
|
||||
@@ -341,6 +341,16 @@ suite('single-element binding effects', function() {
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user