-
Notifications
You must be signed in to change notification settings - Fork 2k
Support ES6 getters and setters for data binding #4815
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
4443c6f
1b17b88
a7e0367
2d9b751
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1760,6 +1760,51 @@ | |
|
||
}); | ||
|
||
suite('ES6 getters/setters', function() { | ||
test('notify path bypasses internal cache to update template', function(done) { | ||
let el = document.createElement('x-getters-setters'); | ||
el.prop1 = 'prop1'; | ||
document.body.appendChild(el); | ||
setTimeout(() => { | ||
let originalProp2 = el.$.prop2.innerText; | ||
assert.equal(el.$.prop1.innerText, 'prop1'); | ||
assert.equal(originalProp2.indexOf('prop2'), 0); | ||
assert.equal(el.$.addProps.innerText.indexOf('prop1 prop2'), 0); | ||
assert.equal(el.$.prop1TwoWay.value, 'prop1'); | ||
let originalProp2TwoWay = el.$.prop2TwoWay.value; | ||
assert.equal(originalProp2TwoWay.indexOf('prop2'), 0); | ||
|
||
el.prop1_ = 'prop1changed'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would also like to see a test that sets both prop1 and prop2 and asserts that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh and initially I missed the fact that this is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I initially had that but removed it. Since |
||
el.notifyPath('prop1'); | ||
el.notifyPath('prop2'); | ||
setTimeout(() => { | ||
assert.equal(el.$.prop1.innerText, 'prop1changed'); | ||
assert.equal(el.$.addProps.innerText.indexOf('prop1changed prop2'), 0); | ||
assert.equal(el.$.prop1TwoWay.value, 'prop1changed'); | ||
assert.notEqual(el.$.prop2.innerText, originalProp2); | ||
assert.notEqual(el.$.prop2TwoWay.value, originalProp2TwoWay); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
test('setters update template', function(done) { | ||
let el = document.createElement('x-getters-setters'); | ||
el.prop1 = 'prop1'; | ||
document.body.appendChild(el); | ||
setTimeout(() => { | ||
assert.equal(el.$.prop1.innerText, 'prop1'); | ||
assert.equal(el.$.addProps.innerText.indexOf('prop1 prop2'), 0); | ||
|
||
el.prop1 = 'prop1changed'; | ||
setTimeout(() => { | ||
assert.equal(el.$.prop1.innerText, 'prop1changed'); | ||
assert.equal(el.$.addProps.innerText.indexOf('prop1changed prop2'), 0); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
</script> | ||
|
||
</body> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this code here instead of in
_createPropertyAccessor
, any particular reason?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My thinking was since this was adding a property effect - it shouldn't be in property accessors. I was trying to consider the cases where PropertyAccessors was mixed in without mixing in PropertyEffects.