-
Notifications
You must be signed in to change notification settings - Fork 215
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
Remove logic from NativeControls.deserializedFromTemplate and hook off the element's setter #96
Conversation
…turn the same value.
…e to the setter of the element property
…. Eg: phone # field in the input-text-example.html
…ativeControl prototype chain
//var component = Object.getPrototypeOf(NativeControl); | ||
// call super set | ||
Object.getPropertyDescriptor(Component, "element").set.call(this, value); | ||
this._elementSet(); |
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.
I think we should be using didSetElement for this.
https://github.com/Motorola-Mobility/montage/blob/master/ui/component.js#L1781
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.
Changed to didSetElement.
@function external:String.isString() | ||
@param {object} obj The object to determine if its a String. | ||
@returns {boolean} Object.prototype.toString.call(obj) === "[object String]" | ||
*/ |
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.
Wondering why is typeof(obj) === 'string' not enough?
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.
It might be because of the following reason:
- typeof "foo" -> "string"
But typeof (new String('foo')) -> "object" - Object.prototype.toString.call("foo") -> "[object String]"
- Object.prototype.toString.call(new String('foo')) -> "[object String]"
The 2nd option is more correct regardless of whether the String value or String Object is used.
Moved the logic from deserializedFromTemplate to _elementSet which is invoked on element.setter. Since the element setter is called before the binding occurs, I also made some changes to handle this.
@francoisfrisch: Also includes implementing attribute properties on the prototype chain.