-
Notifications
You must be signed in to change notification settings - Fork 0
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
Adds the ability to pass a conversion object like JSON #15
Conversation
from-attribute.js
Outdated
@@ -24,7 +32,12 @@ function initializeFromAttribute (propertyName, ctr, attributeName) { | |||
if (ctr[metaSymbol]._attributeChangedCallbackHandler === undefined) { | |||
ctr[metaSymbol]._attributeChangedCallbackHandler = {}; | |||
} | |||
if (attributeName === undefined) { | |||
if (typeof attributeName === 'object') { | |||
if (isJSONLike(attributeName)) { |
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.
Can we give a warning when the wrong thing is passed? This can happen in a future PR.
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.
This looks good. I just had one small comment. Also, we'll need to document these uses, but we can do that in a future PR if you want.
} | ||
|
||
attributes.forEach(attribute => { | ||
const makeFromAttribute = fromAttribute(attribute, JSON); |
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.
We should make sure that this works correctly if attribute
is different from the attribute passed in setAttribute
.
@phillipskevin I updated the PR as requested, can you review it again, please? |
Fixes #11
Make it possible to pass a JSON like conversion object:
person: { type: Object, bind: fromAttribute( JSON ) }
or:
person: { type: Object, bind: fromAttribute( 'attr-name', JSON ) }