Skip to content
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

Merged
merged 10 commits into from
Feb 8, 2012

Conversation

kishores
Copy link
Contributor

@kishores kishores commented Feb 6, 2012

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.

//var component = Object.getPrototypeOf(NativeControl);
// call super set
Object.getPropertyDescriptor(Component, "element").set.call(this, value);
this._elementSet();
Copy link
Contributor

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

Copy link
Contributor Author

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]"
*/
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@francoisfrisch francoisfrisch merged commit 1ba5702 into montagejs:master Feb 8, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants