diff options
author | Nivesh Rajbhandari | 2012-04-25 13:34:04 -0700 |
---|---|---|
committer | Nivesh Rajbhandari | 2012-04-25 13:34:04 -0700 |
commit | 32a24988add5ba0ecf80caa31871cdd90e3eea5b (patch) | |
tree | fbf05f2dfc91e57ab9598046ff16798ea0ae1966 /node_modules/montage/ui/component.js | |
parent | 60d6346a78fb5257eaf36f17a5fcb764a342c012 (diff) | |
parent | d3a6350163ada5644d34ed8d5c2a00cef4db2afc (diff) | |
download | ninja-32a24988add5ba0ecf80caa31871cdd90e3eea5b.tar.gz |
Merge branch 'refs/heads/ninja-internal' into WebGLMaterials
Diffstat (limited to 'node_modules/montage/ui/component.js')
-rwxr-xr-x | node_modules/montage/ui/component.js | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/node_modules/montage/ui/component.js b/node_modules/montage/ui/component.js index 69559fc1..17f87b62 100755 --- a/node_modules/montage/ui/component.js +++ b/node_modules/montage/ui/component.js | |||
@@ -136,23 +136,32 @@ var Component = exports.Component = Montage.create(Montage,/** @lends module:mon | |||
136 | }, | 136 | }, |
137 | set: function(value) { | 137 | set: function(value) { |
138 | if (value == null) { | 138 | if (value == null) { |
139 | console.log("Warning: Tried to set element of ", this, " as " + value + "."); | 139 | console.warn("Tried to set element of ", this, " to ", value); |
140 | return; | 140 | return; |
141 | } | 141 | } |
142 | 142 | ||
143 | this.eventManager.registerEventHandlerForElement(this, value); | ||
144 | |||
145 | if (this.isDeserializing) { | 143 | if (this.isDeserializing) { |
144 | this.eventManager.registerEventHandlerForElement(this, value); | ||
145 | |||
146 | // if this component has a template and has been already instantiated then assume the value is the template. | 146 | // if this component has a template and has been already instantiated then assume the value is the template. |
147 | if (this._isTemplateInstantiated) { | 147 | if (this._isTemplateInstantiated) { |
148 | this._templateElement = value; | 148 | // this is important for component extension, we don't want to override template element |
149 | if (!this._templateElement) { | ||
150 | this._templateElement = value; | ||
151 | } | ||
149 | } else { | 152 | } else { |
150 | this._element = value; | 153 | this._element = value; |
151 | if (!this.blockDrawGate.value && this._element) { | 154 | if (!this.blockDrawGate.value && this._element) { |
152 | this.blockDrawGate.setField("element", true); | 155 | this.blockDrawGate.setField("element", true); |
153 | } | 156 | } |
154 | } | 157 | } |
158 | } else if (!this._firstDraw) { | ||
159 | // If a draw has happened then at some point the element has been set | ||
160 | console.error("Cannot change element of ", this, " after it has been set"); | ||
161 | return; | ||
155 | } else { | 162 | } else { |
163 | this.eventManager.registerEventHandlerForElement(this, value); | ||
164 | |||
156 | this._element = value; | 165 | this._element = value; |
157 | if (!this.blockDrawGate.value && this._element) { | 166 | if (!this.blockDrawGate.value && this._element) { |
158 | this.blockDrawGate.setField("element", true); | 167 | this.blockDrawGate.setField("element", true); |
@@ -614,9 +623,9 @@ var Component = exports.Component = Montage.create(Montage,/** @lends module:mon | |||
614 | } | 623 | } |
615 | }, | 624 | }, |
616 | 625 | ||
617 | serializeSelf: { | 626 | serializeProperties: { |
618 | value: function(serializer, propertyNames) { | 627 | value: function(serializer) { |
619 | serializer.setProperties(propertyNames); | 628 | serializer.setAll(); |
620 | var childComponents = this.childComponents; | 629 | var childComponents = this.childComponents; |
621 | for (var i = 0, l = childComponents.length; i < l; i++) { | 630 | for (var i = 0, l = childComponents.length; i < l; i++) { |
622 | serializer.addObject(childComponents[i]); | 631 | serializer.addObject(childComponents[i]); |