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/core/core.js | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'node_modules/montage/core/core.js') diff --git a/node_modules/montage/core/core.js b/node_modules/montage/core/core.js index 80597dce..26733c94 100755 --- a/node_modules/montage/core/core.js +++ b/node_modules/montage/core/core.js @@ -21,6 +21,7 @@ var ATTRIBUTE_PROPERTIES = "AttributeProperties", PROTO = "__proto__", VALUE = "value", ENUMERABLE = "enumerable", + DISTINCT = "distinct", SERIALIZABLE = "serializable", MODIFY = "modify"; @@ -63,10 +64,6 @@ Object.defineProperty(Montage, "create", { var newObject = Object.create(typeof aPrototype === "undefined" ? this : aPrototype); - if (newObject._dependenciesForProperty) { - newObject._dependencyListeners = {}; - } - if (typeof newObject.didCreate === "function") { newObject.didCreate(); } @@ -80,7 +77,7 @@ Object.defineProperty(Montage, "create", { } }); -var extendedPropertyAttributes = [SERIALIZABLE, MODIFY]; +var extendedPropertyAttributes = [SERIALIZABLE]; // Extended property attributes, the property name format is "_" + attributeName + "AttributeProperties" /** @@ -112,13 +109,21 @@ extendedPropertyAttributes.forEach(function(name) { Object.defineProperty(Montage, "defineProperty", { value: function(obj, prop, descriptor) { - var dependencies = descriptor.dependencies; + + var dependencies = descriptor.dependencies, + isValueDescriptor = (VALUE in descriptor); + + if (DISTINCT in descriptor && !isValueDescriptor) { + throw ("Cannot use distinct attribute on non-value property '" + prop + "'"); + } + + //reset defaults appropriately for framework. if (PROTO in descriptor) { - descriptor.__proto__ = (VALUE in descriptor ? (typeof descriptor.value === "function" ? _defaultFunctionValueProperty : _defaultObjectValueProperty) : _defaultAccessorProperty); + descriptor.__proto__ = (isValueDescriptor ? (typeof descriptor.value === "function" ? _defaultFunctionValueProperty : _defaultObjectValueProperty) : _defaultAccessorProperty); } else { var defaults; - if (VALUE in descriptor) { + if (isValueDescriptor) { if (typeof descriptor.value === "function") { defaults = _defaultFunctionValueProperty; } else { @@ -153,10 +158,6 @@ Object.defineProperty(Montage, "defineProperty", { getAttributeProperties(obj, SERIALIZABLE)[prop] = descriptor.serializable; } - if (MODIFY in descriptor) { - getAttributeProperties(obj, MODIFY)[prop] = descriptor.modify; - } - //this is added to enable value properties with [] or Objects that are new for every instance if (descriptor.distinct === true && typeof descriptor.value === "object") { (function(prop,internalProperty, value, obj) { @@ -587,6 +588,11 @@ Object.defineProperty(Object.prototype, "uuid", { } }); +Montage.defineProperty(Montage, "identifier", { + value: null, + serializable: true +}); + /** Returns true if two objects are equal, otherwise returns false. @function module:montage/core/core.Montage#equals @@ -599,6 +605,8 @@ Object.defineProperty(Montage, "equals", { } }); + + /* * If it exists this method calls the method named with the identifier prefix. * Example: If the name parameter is "shouldDoSomething" and the caller's identifier is "bob", then -- cgit v1.2.3