From f7e4257745ccd44b8d24555f0ef787429d6e472c Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 5 Jun 2012 00:11:03 -0700 Subject: adding the latest v0.10 montage Signed-off-by: Valerio Virgillito --- node_modules/montage/ui/native-control.js | 50 ++++++++++++++++++------------- 1 file changed, 30 insertions(+), 20 deletions(-) (limited to 'node_modules/montage/ui/native-control.js') diff --git a/node_modules/montage/ui/native-control.js b/node_modules/montage/ui/native-control.js index 8dad5408..b44d2cac 100644 --- a/node_modules/montage/ui/native-control.js +++ b/node_modules/montage/ui/native-control.js @@ -96,7 +96,6 @@ var NativeControl = exports.NativeControl = Montage.create(Component, /** @lends var newDescriptor = { configurable: (typeof descriptor.configurable == 'undefined') ? true: descriptor.configurable, enumerable: (typeof descriptor.enumerable == 'undefined') ? true: descriptor.enumerable, - serializable: (typeof descriptor.serializable == 'undefined') ? true: descriptor.serializable, set: (function(name, attrName) { return function(value) { var desc = this._getElementAttributeDescriptor(name, this); @@ -121,7 +120,8 @@ var NativeControl = exports.NativeControl = Montage.create(Component, /** @lends return function() { return this[attrName]; }; - }(name, _name)) + }(name, _name)), + serializable: true }; // Define _ property @@ -175,10 +175,15 @@ var NativeControl = exports.NativeControl = Montage.create(Component, /** @lends name = attributes[i].name; value = attributes[i].value; - if(typeof this._elementAttributeValues[name] == 'undefined') { - this._elementAttributeValues[name] = value; - if( (typeof this[name] == 'undefined') || this[name] == null) { - this[name] = value; + descriptor = this._getElementAttributeDescriptor(name, this); + // check if this attribute from the markup is a well-defined attribute of the component + if(descriptor || (typeof this[name] !== 'undefined')) { + // only set the value if a value has not already been set by binding + if(typeof this._elementAttributeValues[name] == 'undefined') { + this._elementAttributeValues[name] = value; + if( (typeof this[name] == 'undefined') || this[name] == null) { + this[name] = value; + } } } } @@ -218,25 +223,30 @@ var NativeControl = exports.NativeControl = Montage.create(Component, /** @lends if(this._elementAttributeValues.hasOwnProperty(attributeName)) { var value = this[attributeName]; descriptor = this._getElementAttributeDescriptor(attributeName, this); - if(descriptor && descriptor.dataType === 'boolean') { - if(value === true) { - element[attributeName] = true; - element.setAttribute(attributeName, attributeName.toLowerCase()); - } else { - element[attributeName] = false; - element.removeAttribute(attributeName); - } - } else { - if(typeof value !== 'undefined') { - if(attributeName === 'textContent') { - element.textContent = value; + if(descriptor) { + + if(descriptor.dataType === 'boolean') { + if(value === true) { + element[attributeName] = true; + element.setAttribute(attributeName, attributeName.toLowerCase()); } else { - //https://developer.mozilla.org/en/DOM/element.setAttribute - element.setAttribute(attributeName, value); + element[attributeName] = false; + element.removeAttribute(attributeName); } + } else { + if(typeof value !== 'undefined') { + if(attributeName === 'textContent') { + element.textContent = value; + } else { + //https://developer.mozilla.org/en/DOM/element.setAttribute + element.setAttribute(attributeName, value); + } + } } + } + delete this._elementAttributeValues[attributeName]; } } -- cgit v1.2.3