diff options
author | Armen Kesablyan | 2012-06-19 00:45:26 -0700 |
---|---|---|
committer | Armen Kesablyan | 2012-06-19 00:45:26 -0700 |
commit | c59eb371559a3061ce53223e249ca97daace5968 (patch) | |
tree | f9540e26c0f273d35f92010605da65dd85bbe70c /node_modules/montage/ui/native-control.js | |
parent | 0f040acabfb7a4bf3138debec5aff869487ceb11 (diff) | |
parent | 918a4f5870e972b6e4e301c3237e065a1ffd26f5 (diff) | |
download | ninja-c59eb371559a3061ce53223e249ca97daace5968.tar.gz |
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal
Diffstat (limited to 'node_modules/montage/ui/native-control.js')
-rw-r--r-- | node_modules/montage/ui/native-control.js | 50 |
1 files changed, 30 insertions, 20 deletions
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 | |||
96 | var newDescriptor = { | 96 | var newDescriptor = { |
97 | configurable: (typeof descriptor.configurable == 'undefined') ? true: descriptor.configurable, | 97 | configurable: (typeof descriptor.configurable == 'undefined') ? true: descriptor.configurable, |
98 | enumerable: (typeof descriptor.enumerable == 'undefined') ? true: descriptor.enumerable, | 98 | enumerable: (typeof descriptor.enumerable == 'undefined') ? true: descriptor.enumerable, |
99 | serializable: (typeof descriptor.serializable == 'undefined') ? true: descriptor.serializable, | ||
100 | set: (function(name, attrName) { | 99 | set: (function(name, attrName) { |
101 | return function(value) { | 100 | return function(value) { |
102 | var desc = this._getElementAttributeDescriptor(name, this); | 101 | var desc = this._getElementAttributeDescriptor(name, this); |
@@ -121,7 +120,8 @@ var NativeControl = exports.NativeControl = Montage.create(Component, /** @lends | |||
121 | return function() { | 120 | return function() { |
122 | return this[attrName]; | 121 | return this[attrName]; |
123 | }; | 122 | }; |
124 | }(name, _name)) | 123 | }(name, _name)), |
124 | serializable: true | ||
125 | }; | 125 | }; |
126 | 126 | ||
127 | // Define _ property | 127 | // Define _ property |
@@ -175,10 +175,15 @@ var NativeControl = exports.NativeControl = Montage.create(Component, /** @lends | |||
175 | name = attributes[i].name; | 175 | name = attributes[i].name; |
176 | value = attributes[i].value; | 176 | value = attributes[i].value; |
177 | 177 | ||
178 | if(typeof this._elementAttributeValues[name] == 'undefined') { | 178 | descriptor = this._getElementAttributeDescriptor(name, this); |
179 | this._elementAttributeValues[name] = value; | 179 | // check if this attribute from the markup is a well-defined attribute of the component |
180 | if( (typeof this[name] == 'undefined') || this[name] == null) { | 180 | if(descriptor || (typeof this[name] !== 'undefined')) { |
181 | this[name] = value; | 181 | // only set the value if a value has not already been set by binding |
182 | if(typeof this._elementAttributeValues[name] == 'undefined') { | ||
183 | this._elementAttributeValues[name] = value; | ||
184 | if( (typeof this[name] == 'undefined') || this[name] == null) { | ||
185 | this[name] = value; | ||
186 | } | ||
182 | } | 187 | } |
183 | } | 188 | } |
184 | } | 189 | } |
@@ -218,25 +223,30 @@ var NativeControl = exports.NativeControl = Montage.create(Component, /** @lends | |||
218 | if(this._elementAttributeValues.hasOwnProperty(attributeName)) { | 223 | if(this._elementAttributeValues.hasOwnProperty(attributeName)) { |
219 | var value = this[attributeName]; | 224 | var value = this[attributeName]; |
220 | descriptor = this._getElementAttributeDescriptor(attributeName, this); | 225 | descriptor = this._getElementAttributeDescriptor(attributeName, this); |
221 | if(descriptor && descriptor.dataType === 'boolean') { | 226 | if(descriptor) { |
222 | if(value === true) { | 227 | |
223 | element[attributeName] = true; | 228 | if(descriptor.dataType === 'boolean') { |
224 | element.setAttribute(attributeName, attributeName.toLowerCase()); | 229 | if(value === true) { |
225 | } else { | 230 | element[attributeName] = true; |
226 | element[attributeName] = false; | 231 | element.setAttribute(attributeName, attributeName.toLowerCase()); |
227 | element.removeAttribute(attributeName); | ||
228 | } | ||
229 | } else { | ||
230 | if(typeof value !== 'undefined') { | ||
231 | if(attributeName === 'textContent') { | ||
232 | element.textContent = value; | ||
233 | } else { | 232 | } else { |
234 | //https://developer.mozilla.org/en/DOM/element.setAttribute | 233 | element[attributeName] = false; |
235 | element.setAttribute(attributeName, value); | 234 | element.removeAttribute(attributeName); |
236 | } | 235 | } |
236 | } else { | ||
237 | if(typeof value !== 'undefined') { | ||
238 | if(attributeName === 'textContent') { | ||
239 | element.textContent = value; | ||
240 | } else { | ||
241 | //https://developer.mozilla.org/en/DOM/element.setAttribute | ||
242 | element.setAttribute(attributeName, value); | ||
243 | } | ||
237 | 244 | ||
245 | } | ||
238 | } | 246 | } |
247 | |||
239 | } | 248 | } |
249 | |||
240 | delete this._elementAttributeValues[attributeName]; | 250 | delete this._elementAttributeValues[attributeName]; |
241 | } | 251 | } |
242 | } | 252 | } |