diff options
Diffstat (limited to 'node_modules/montage/core')
-rwxr-xr-x | node_modules/montage/core/converter/date-converter.js | 9 | ||||
-rwxr-xr-x | node_modules/montage/core/core.js | 26 | ||||
-rwxr-xr-x | node_modules/montage/core/deserializer.js | 104 | ||||
-rwxr-xr-x | node_modules/montage/core/event/binding.js | 93 | ||||
-rwxr-xr-x | node_modules/montage/core/event/event-manager.js | 15 | ||||
-rwxr-xr-x | node_modules/montage/core/event/mutable-event.js | 5 | ||||
-rwxr-xr-x | node_modules/montage/core/jshint.js | 2 | ||||
-rwxr-xr-x | node_modules/montage/core/logger.js | 14 | ||||
-rw-r--r-- | node_modules/montage/core/next-tick.js | 91 | ||||
-rwxr-xr-x | node_modules/montage/core/promise.js | 115 | ||||
-rwxr-xr-x | node_modules/montage/core/serializer.js | 21 | ||||
-rwxr-xr-x | node_modules/montage/core/shim.js | 2 | ||||
-rw-r--r--[-rwxr-xr-x] | node_modules/montage/core/shim/immediate.js (renamed from node_modules/montage/core/shim/timers.js) | 44 | ||||
-rwxr-xr-x | node_modules/montage/core/shim/structures.js | 22 | ||||
-rw-r--r-- | node_modules/montage/core/url.js | 2 | ||||
-rwxr-xr-x | node_modules/montage/core/uuid.js | 96 |
16 files changed, 408 insertions, 253 deletions
diff --git a/node_modules/montage/core/converter/date-converter.js b/node_modules/montage/core/converter/date-converter.js index b00a5b22..f0d3e540 100755 --- a/node_modules/montage/core/converter/date-converter.js +++ b/node_modules/montage/core/converter/date-converter.js | |||
@@ -2573,6 +2573,15 @@ var DateValidator = exports.DateValidator = Montage.create(Validator,/** @lends | |||
2573 | @class module:montage/core/converter/date-converter.DateConverter | 2573 | @class module:montage/core/converter/date-converter.DateConverter |
2574 | */ | 2574 | */ |
2575 | var DateConverter = exports.DateConverter = Montage.create(Converter,/** @lends module:montage/core/converter/date-converter.DateConverter# */ { | 2575 | var DateConverter = exports.DateConverter = Montage.create(Converter,/** @lends module:montage/core/converter/date-converter.DateConverter# */ { |
2576 | /** | ||
2577 | Specifies whether the converter allows partial conversion. | ||
2578 | @type {Property} | ||
2579 | @default {Boolean} true | ||
2580 | */ | ||
2581 | allowPartialConversion: { | ||
2582 | value: false | ||
2583 | }, | ||
2584 | |||
2576 | /** | 2585 | /** |
2577 | @type {Property} | 2586 | @type {Property} |
2578 | @default {Function} Montage.create(DateValidator) | 2587 | @default {Function} Montage.create(DateValidator) |
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 | |||
788 | */ | 788 | */ |
789 | Object.defineProperty(Object.prototype, "setProperty", { | 789 | Object.defineProperty(Object.prototype, "setProperty", { |
790 | value: function(aPropertyPath, value) { | 790 | value: function(aPropertyPath, value) { |
791 | var lastDotIndex = aPropertyPath.lastIndexOf("."), | 791 | var propertyIsNumber = !isNaN(aPropertyPath), |
792 | lastDotIndex = propertyIsNumber ? -1 : aPropertyPath.lastIndexOf("."), | ||
792 | setObject, | 793 | setObject, |
793 | lastObjectAtPath, | 794 | lastObjectAtPath, |
794 | propertyToSetOnArray; | 795 | propertyToSetOnArray; |
@@ -883,9 +884,10 @@ Object.defineProperty(Array.prototype, "getProperty", { | |||
883 | currentIndex = currentIndex || 0; | 884 | currentIndex = currentIndex || 0; |
884 | 885 | ||
885 | var result, | 886 | var result, |
886 | parenthesisStartIndex = aPropertyPath.indexOf("(", currentIndex), | 887 | propertyIsNumber = !isNaN(aPropertyPath), |
887 | parenthesisEndIndex = aPropertyPath.lastIndexOf(")"), | 888 | parenthesisStartIndex = propertyIsNumber ? -1 : aPropertyPath.indexOf("(", currentIndex), |
888 | currentPathComponentEndIndex = aPropertyPath.indexOf(".", currentIndex), | 889 | parenthesisEndIndex = propertyIsNumber ? -1 : aPropertyPath.lastIndexOf(")"), |
890 | currentPathComponentEndIndex = propertyIsNumber ? -1 : aPropertyPath.indexOf(".", currentIndex), | ||
889 | nextDelimiterIndex = -1, | 891 | nextDelimiterIndex = -1, |
890 | itemResult, | 892 | itemResult, |
891 | index, | 893 | index, |
@@ -917,7 +919,7 @@ Object.defineProperty(Array.prototype, "getProperty", { | |||
917 | } | 919 | } |
918 | 920 | ||
919 | // Find the component of the propertyPath we want to deal with during this particular invocation of this function | 921 | // Find the component of the propertyPath we want to deal with during this particular invocation of this function |
920 | currentPathComponent = aPropertyPath.substring(currentIndex, (nextDelimiterIndex === -1 ? aPropertyPath.length : nextDelimiterIndex)); | 922 | currentPathComponent = propertyIsNumber ? aPropertyPath : aPropertyPath.substring(currentIndex, (nextDelimiterIndex === -1 ? aPropertyPath.length : nextDelimiterIndex)); |
921 | 923 | ||
922 | // EVALUATE: Determine the value of the currentPathComponent | 924 | // EVALUATE: Determine the value of the currentPathComponent |
923 | 925 | ||
@@ -1115,8 +1117,14 @@ Object.defineProperty(Object.prototype, "parentProperty", { | |||
1115 | writable: true | 1117 | writable: true |
1116 | }); | 1118 | }); |
1117 | 1119 | ||
1118 | var EventManager = require("core/event/event-manager").EventManager; | 1120 | // XXX Does not presently function server-side |
1119 | EventManager.create().initWithWindow(window); | 1121 | if (typeof window !== "undefined") { |
1122 | |||
1123 | var EventManager = require("core/event/event-manager").EventManager; | ||
1124 | EventManager.create().initWithWindow(window); | ||
1125 | |||
1126 | // Now that we have a defaultEventManager we can setup the bindings system | ||
1127 | require("core/event/binding"); | ||
1128 | |||
1129 | } | ||
1120 | 1130 | ||
1121 | // Now that we have a defaultEventManager we can setup the bindings system | ||
1122 | require("core/event/binding"); | ||
diff --git a/node_modules/montage/core/deserializer.js b/node_modules/montage/core/deserializer.js index 8f1f0831..09635153 100755 --- a/node_modules/montage/core/deserializer.js +++ b/node_modules/montage/core/deserializer.js | |||
@@ -15,11 +15,17 @@ var Montage = require("montage").Montage, | |||
15 | logger = require("core/logger").logger("deserializer"), | 15 | logger = require("core/logger").logger("deserializer"), |
16 | Promise = require("core/promise").Promise; | 16 | Promise = require("core/promise").Promise; |
17 | 17 | ||
18 | // By rebinding eval to a new name, it loses its ability to | ||
19 | // capture the calling scope. | ||
20 | var globalEval = eval; | ||
21 | |||
18 | /** | 22 | /** |
19 | @class module:montage/core/deserializer.Deserializer | 23 | @class module:montage/core/deserializer.Deserializer |
20 | @extends module:montage/core/core.Montage | 24 | @extends module:montage/core/core.Montage |
21 | */ | 25 | */ |
22 | var Deserializer = Montage.create(Montage, /** @lends module:montage/core/deserializer.Deserializer# */ { | 26 | var Deserializer = Montage.create(Montage, /** @lends module:montage/core/deserializer.Deserializer# */ { |
27 | _MONTAGE_ID_ATTRIBUTE: {value: "data-montage-id"}, | ||
28 | |||
23 | _objects: {value: null}, | 29 | _objects: {value: null}, |
24 | /** | 30 | /** |
25 | @private | 31 | @private |
@@ -51,6 +57,13 @@ var Deserializer = Montage.create(Montage, /** @lends module:montage/core/deseri | |||
51 | /** | 57 | /** |
52 | @private | 58 | @private |
53 | */ | 59 | */ |
60 | |||
61 | /** | ||
62 | @private | ||
63 | */ | ||
64 | // list of ids that were just created for optimization | ||
65 | _optimizedIds: {value: {}}, | ||
66 | |||
54 | _indexedDeserializationUnits: {value: {}}, | 67 | _indexedDeserializationUnits: {value: {}}, |
55 | 68 | ||
56 | __sharedDocument: { | 69 | __sharedDocument: { |
@@ -365,6 +378,27 @@ var Deserializer = Montage.create(Montage, /** @lends module:montage/core/deseri | |||
365 | this._compileAndDeserialize(); | 378 | this._compileAndDeserialize(); |
366 | return this._compiledDeserializationFunctionString; | 379 | return this._compiledDeserializationFunctionString; |
367 | }}, | 380 | }}, |
381 | |||
382 | /** | ||
383 | * Optimizes the current serialization for a specific document. | ||
384 | * @function | ||
385 | * @param {Document} doc The document to optimize against, this document can be modified during optimization. | ||
386 | */ | ||
387 | optimizeForDocument: { | ||
388 | value: function(doc) { | ||
389 | var idAttributeName = Deserializer._MONTAGE_ID_ATTRIBUTE, | ||
390 | elements = doc.querySelectorAll('*[' + idAttributeName + ']'), | ||
391 | ids = this._optimizedIds = {}; | ||
392 | |||
393 | for (var i = 0, element; (element = elements[i]); i++) { | ||
394 | if (!element.id) { | ||
395 | var attribute = element.getAttribute(idAttributeName); | ||
396 | element.setAttribute("id", ids[attribute] = "_" + idAttributeName + "_" + attribute); | ||
397 | } | ||
398 | } | ||
399 | } | ||
400 | }, | ||
401 | |||
368 | /** | 402 | /** |
369 | @private | 403 | @private |
370 | */ | 404 | */ |
@@ -374,9 +408,12 @@ var Deserializer = Montage.create(Montage, /** @lends module:montage/core/deseri | |||
374 | exportsStrings = "", | 408 | exportsStrings = "", |
375 | unitsStrings = "", | 409 | unitsStrings = "", |
376 | objectsStrings = "", | 410 | objectsStrings = "", |
411 | cleanupStrings = "", | ||
377 | valueString, | 412 | valueString, |
378 | exports = {}, | 413 | exports = {}, |
379 | modules = this._modules, | 414 | modules = this._modules, |
415 | idsToRemove = [], | ||
416 | optimizedIds = this._optimizedIds, | ||
380 | requireStrings = [], | 417 | requireStrings = [], |
381 | objectNamesCounter = {}, | 418 | objectNamesCounter = {}, |
382 | label; | 419 | label; |
@@ -408,8 +445,17 @@ var Deserializer = Montage.create(Montage, /** @lends module:montage/core/deseri | |||
408 | } | 445 | } |
409 | } | 446 | } |
410 | 447 | ||
411 | this._compiledDeserializationFunctionString = "(function() {\n" + requireStrings.join("\n") + "\nreturn function(element) {\nvar exports = {};\n" + exportsStrings + "\n\n" + objectsStrings + "\n\n" + unitsStrings + "\nreturn exports;\n}}).call(this)"; | 448 | if (idsToRemove.length > 0) { |
412 | //console.log(this._compiledDeserializationFunctionString); | 449 | cleanupStrings = 'element.getElementById("' + idsToRemove.join('").removeAttribute("id");\nelement.getElementById("') + '").removeAttribute("id");'; |
450 | for (var i = 0, id; (id = idsToRemove[i]); i++) { | ||
451 | element.getElementById(idsToRemove[i]).removeAttribute("id"); | ||
452 | } | ||
453 | } | ||
454 | |||
455 | this._compiledDeserializationFunctionString = "(function() {\n" + requireStrings.join("\n") + "\nreturn function(element) {\nvar exports = {};\n" + exportsStrings + "\n\n" + objectsStrings + "\n\n" + unitsStrings + "\n\n" + cleanupStrings + "\nreturn exports;\n}}).call(this)"; | ||
456 | if (logger.isDebug) { | ||
457 | logger.debug(this._compiledDeserializationFunctionString); | ||
458 | } | ||
413 | 459 | ||
414 | this._serialization = serialization = null; | 460 | this._serialization = serialization = null; |
415 | 461 | ||
@@ -490,7 +536,7 @@ var Deserializer = Montage.create(Montage, /** @lends module:montage/core/deseri | |||
490 | } else if (value === null) { | 536 | } else if (value === null) { |