From a3024011a91d3941f81481dd4d600e9684eb0fd4 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 2 Feb 2012 00:11:51 -0800 Subject: upgrading to Montage v0.6 Signed-off-by: Valerio Virgillito --- node_modules/montage/core/core.js | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 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 b665f591..8c1f4249 100755 --- a/node_modules/montage/core/core.js +++ b/node_modules/montage/core/core.js @@ -788,7 +788,8 @@ Description */ Object.defineProperty(Object.prototype, "setProperty", { value: function(aPropertyPath, value) { - var lastDotIndex = aPropertyPath.lastIndexOf("."), + var propertyIsNumber = !isNaN(aPropertyPath), + lastDotIndex = propertyIsNumber ? -1 : aPropertyPath.lastIndexOf("."), setObject, lastObjectAtPath, propertyToSetOnArray; @@ -883,9 +884,10 @@ Object.defineProperty(Array.prototype, "getProperty", { currentIndex = currentIndex || 0; var result, - parenthesisStartIndex = aPropertyPath.indexOf("(", currentIndex), - parenthesisEndIndex = aPropertyPath.lastIndexOf(")"), - currentPathComponentEndIndex = aPropertyPath.indexOf(".", currentIndex), + propertyIsNumber = !isNaN(aPropertyPath), + parenthesisStartIndex = propertyIsNumber ? -1 : aPropertyPath.indexOf("(", currentIndex), + parenthesisEndIndex = propertyIsNumber ? -1 : aPropertyPath.lastIndexOf(")"), + currentPathComponentEndIndex = propertyIsNumber ? -1 : aPropertyPath.indexOf(".", currentIndex), nextDelimiterIndex = -1, itemResult, index, @@ -917,7 +919,7 @@ Object.defineProperty(Array.prototype, "getProperty", { } // Find the component of the propertyPath we want to deal with during this particular invocation of this function - currentPathComponent = aPropertyPath.substring(currentIndex, (nextDelimiterIndex === -1 ? aPropertyPath.length : nextDelimiterIndex)); + currentPathComponent = propertyIsNumber ? aPropertyPath : aPropertyPath.substring(currentIndex, (nextDelimiterIndex === -1 ? aPropertyPath.length : nextDelimiterIndex)); // EVALUATE: Determine the value of the currentPathComponent @@ -1115,8 +1117,14 @@ Object.defineProperty(Object.prototype, "parentProperty", { writable: true }); -var EventManager = require("core/event/event-manager").EventManager; -EventManager.create().initWithWindow(window); +// XXX Does not presently function server-side +if (typeof window !== "undefined") { + + var EventManager = require("core/event/event-manager").EventManager; + EventManager.create().initWithWindow(window); + + // Now that we have a defaultEventManager we can setup the bindings system + require("core/event/binding"); + +} -// Now that we have a defaultEventManager we can setup the bindings system -require("core/event/binding"); -- cgit v1.2.3