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 --- .../montage/core/converter/date-converter.js | 9 + node_modules/montage/core/core.js | 26 +- node_modules/montage/core/deserializer.js | 104 +- node_modules/montage/core/event/binding.js | 93 +- node_modules/montage/core/event/event-manager.js | 15 +- node_modules/montage/core/event/mutable-event.js | 5 + node_modules/montage/core/jshint.js | 2 +- node_modules/montage/core/logger.js | 14 +- node_modules/montage/core/next-tick.js | 91 ++ node_modules/montage/core/promise.js | 115 +- node_modules/montage/core/serializer.js | 21 +- node_modules/montage/core/shim.js | 2 - node_modules/montage/core/shim/immediate.js | 57 + node_modules/montage/core/shim/structures.js | 22 +- node_modules/montage/core/shim/timers.js | 87 -- node_modules/montage/core/url.js | 2 +- node_modules/montage/core/uuid.js | 96 +- node_modules/montage/effect/desaturate-effect.js | 25 - node_modules/montage/effect/effect.js | 15 - node_modules/montage/effect/invert-effect.js | 23 - node_modules/montage/effect/kaliedoscope-effect.js | 17 - node_modules/montage/effect/multiply-effect.js | 23 - node_modules/montage/effect/sepia-effect.js | 25 - node_modules/montage/montage.js | 213 +-- node_modules/montage/node.js | 79 + node_modules/montage/package.json | 13 +- node_modules/montage/require/browser.js | 183 +-- node_modules/montage/require/node.js | 101 ++ node_modules/montage/require/require.js | 997 +++++------- node_modules/montage/ui/anchor.reel/anchor.js | 26 + node_modules/montage/ui/application.js | 128 +- .../ui/bluemoon/button-group.reel/button-group.css | 111 ++ .../bluemoon/button-group.reel/button-group.html | 26 + .../ui/bluemoon/button-group.reel/button-group.js | 77 + .../montage/ui/bluemoon/button.reel/button.css | 386 +++++ .../montage/ui/bluemoon/button.reel/button.html | 26 + .../montage/ui/bluemoon/button.reel/button.js | 743 +++++++++ .../montage/ui/bluemoon/checkbox.reel/checkbox.css | 116 ++ .../ui/bluemoon/checkbox.reel/checkbox.html | 14 + .../montage/ui/bluemoon/checkbox.reel/checkbox.js | 452 ++++++ .../checkbox.reel/checkmark-dark-disabled.svg | 5 + .../ui/bluemoon/checkbox.reel/checkmark-dark.svg | 7 + .../checkbox.reel/checkmark-light-disabled.svg | 5 + .../ui/bluemoon/checkbox.reel/checkmark.svg | 7 + .../montage/ui/bluemoon/progress.reel/progress.css | 51 + .../ui/bluemoon/progress.reel/progress.html | 32 + .../montage/ui/bluemoon/progress.reel/progress.js | 139 ++ .../montage/ui/bluemoon/progress.reel/rule.png | Bin 0 -> 956 bytes .../montage/ui/bluemoon/progress.reel/scroll.png | Bin 0 -> 272 bytes .../montage/ui/bluemoon/slider.reel/slider.css | 255 +++ .../montage/ui/bluemoon/slider.reel/slider.html | 82 + .../montage/ui/bluemoon/slider.reel/slider.js | 583 +++++++ .../montage/ui/bluemoon/textarea.reel/textarea.css | 36 + .../ui/bluemoon/textarea.reel/textarea.html | 15 + .../montage/ui/bluemoon/textarea.reel/textarea.js | 29 + .../ui/bluemoon/textfield.reel/textfield.css | 35 + .../ui/bluemoon/textfield.reel/textfield.html | 16 + .../ui/bluemoon/textfield.reel/textfield.js | 56 + .../montage/ui/bluemoon/toggle.reel/toggle.css | 162 ++ .../montage/ui/bluemoon/toggle.reel/toggle.html | 16 + .../montage/ui/bluemoon/toggle.reel/toggle.js | 423 +++++ .../montage/ui/button-group.reel/button-group.css | 111 -- .../montage/ui/button-group.reel/button-group.html | 26 - .../montage/ui/button-group.reel/button-group.js | 77 - node_modules/montage/ui/button.reel/button.css | 386 ----- node_modules/montage/ui/button.reel/button.html | 26 - node_modules/montage/ui/button.reel/button.js | 655 ++------ node_modules/montage/ui/check-input.js | 46 + node_modules/montage/ui/checkbox.reel/checkbox.css | 116 -- .../montage/ui/checkbox.reel/checkbox.html | 14 - node_modules/montage/ui/checkbox.reel/checkbox.js | 464 +----- .../ui/checkbox.reel/checkmark-dark-disabled.svg | 5 - .../montage/ui/checkbox.reel/checkmark-dark.svg | 7 - .../ui/checkbox.reel/checkmark-light-disabled.svg | 5 - .../montage/ui/checkbox.reel/checkmark.svg | 7 - node_modules/montage/ui/component.js | 292 +++- node_modules/montage/ui/composer/composer.js | 142 ++ .../montage/ui/composer/long-press-composer.js | 232 +++ node_modules/montage/ui/composer/swipe-composer.js | 303 ++++ .../montage/ui/composer/translate-composer.js | 775 ++++++++++ .../montage/ui/controller/array-controller.js | 73 +- .../montage/ui/date-input.reel/date-input.js | 31 + node_modules/montage/ui/dom.js | 30 +- .../ui/flow-controller.reel/flow-controller.html | 275 ---- .../ui/flow-controller.reel/flow-controller.js | 288 ---- node_modules/montage/ui/flow-offset.js | 389 ----- node_modules/montage/ui/flow-path-cubic.js | 32 +- node_modules/montage/ui/flow-path-lerp.js | 36 +- node_modules/montage/ui/flow-path-linear.js | 26 +- node_modules/montage/ui/flow-path-sigmoid.js | 42 +- node_modules/montage/ui/flow-path.js | 46 +- node_modules/montage/ui/flow.reel/flow.html | 4 +- node_modules/montage/ui/flow.reel/flow.js | 658 ++++++-- node_modules/montage/ui/hottext.reel/hottext.css | 27 - node_modules/montage/ui/hottext.reel/hottext.html | 29 - node_modules/montage/ui/hottext.reel/hottext.js | 376 ----- .../montage/ui/hottextunit.reel/hottextunit.css | 41 - .../montage/ui/hottextunit.reel/hottextunit.html | 28 - .../montage/ui/hottextunit.reel/hottextunit.js | 185 --- node_modules/montage/ui/image.reel/image.js | 65 +- node_modules/montage/ui/image2.reel/image2.html | 31 - node_modules/montage/ui/image2.reel/image2.js | 26 - node_modules/montage/ui/image3d.reel/image3d.html | 95 -- node_modules/montage/ui/image3d.reel/image3d.js | 30 - node_modules/montage/ui/list.reel/list.html | 34 +- node_modules/montage/ui/list.reel/list.js | 192 +-- node_modules/montage/ui/loader.reel/loader.js | 7 + .../ui/loading-panel.reel/loading-panel.html | 2 +- node_modules/montage/ui/native-control.js | 240 +++ .../ui/nearest-neighbor-component-search.js | 458 +++--- .../montage/ui/number-input.reel/number-input.js | 17 + .../montage/ui/photo-editor.reel/photo-editor.css | 34 - .../montage/ui/photo-editor.reel/photo-editor.html | 50 - .../montage/ui/photo-editor.reel/photo-editor.js | 415 ----- node_modules/montage/ui/popup/alert.reel/alert.css | 8 +- .../montage/ui/popup/alert.reel/alert.html | 14 +- .../montage/ui/popup/confirm.reel/confirm.css | 2 +- .../montage/ui/popup/confirm.reel/confirm.html | 16 +- .../montage/ui/popup/confirm.reel/confirm.js | 12 +- node_modules/montage/ui/popup/popup.reel/popup.css | 15 +- .../montage/ui/popup/popup.reel/popup.html | 2 +- node_modules/montage/ui/popup/popup.reel/popup.js | 69 +- .../montage/ui/progress.reel/progress.html | 8 +- node_modules/montage/ui/progress.reel/progress.js | 23 +- .../montage/ui/radio-button.reel/radio-button.js | 97 ++ .../montage/ui/range-input.reel/range-input.js | 24 + .../montage/ui/repetition.reel/repetition.js | 243 +-- .../montage/ui/scroll-bars.reel/scroll-bars.html | 2 +- .../montage/ui/scroll-bars.reel/scroll-bars.js | 14 +- node_modules/montage/ui/scroll.js | 1634 ++++++++++---------- .../montage/ui/scroller.reel/scroller.html | 59 +- node_modules/montage/ui/scroller.reel/scroller.js | 87 +- .../montage/ui/select-input.reel/select-input.js | 320 ++++ node_modules/montage/ui/slider-base.js | 278 ---- node_modules/montage/ui/slider.reel/slider.css | 255 --- node_modules/montage/ui/slider.reel/slider.html | 82 - node_modules/montage/ui/slider.reel/slider.js | 583 ------- node_modules/montage/ui/tabs.reel/tabs.html | 8 +- node_modules/montage/ui/template.js | 47 +- node_modules/montage/ui/text-input.js | 304 ++++ node_modules/montage/ui/textarea.reel/textarea.css | 36 - .../montage/ui/textarea.reel/textarea.html | 15 - node_modules/montage/ui/textarea.reel/textarea.js | 48 +- .../montage/ui/textfield.reel/textfield.css | 35 - .../montage/ui/textfield.reel/textfield.html | 16 - .../montage/ui/textfield.reel/textfield.js | 37 +- .../montage/ui/toggle-button.reel/toggle-button.js | 171 ++ .../ui/toggle-switch.reel/toggle-switch.css | 162 ++ .../ui/toggle-switch.reel/toggle-switch.html | 16 + .../montage/ui/toggle-switch.reel/toggle-switch.js | 424 +++++ node_modules/montage/ui/toggle.reel/toggle.css | 162 -- node_modules/montage/ui/toggle.reel/toggle.html | 16 - node_modules/montage/ui/toggle.reel/toggle.js | 423 ----- .../montage/ui/video-player.reel/video-player.css | 22 +- .../montage/ui/video-player.reel/video-player.html | 18 +- 155 files changed, 11214 insertions(+), 9128 deletions(-) create mode 100644 node_modules/montage/core/next-tick.js create mode 100644 node_modules/montage/core/shim/immediate.js delete mode 100755 node_modules/montage/core/shim/timers.js delete mode 100755 node_modules/montage/effect/desaturate-effect.js delete mode 100755 node_modules/montage/effect/effect.js delete mode 100755 node_modules/montage/effect/invert-effect.js delete mode 100755 node_modules/montage/effect/kaliedoscope-effect.js delete mode 100755 node_modules/montage/effect/multiply-effect.js delete mode 100755 node_modules/montage/effect/sepia-effect.js create mode 100644 node_modules/montage/node.js create mode 100644 node_modules/montage/require/node.js create mode 100644 node_modules/montage/ui/anchor.reel/anchor.js create mode 100644 node_modules/montage/ui/bluemoon/button-group.reel/button-group.css create mode 100644 node_modules/montage/ui/bluemoon/button-group.reel/button-group.html create mode 100644 node_modules/montage/ui/bluemoon/button-group.reel/button-group.js create mode 100644 node_modules/montage/ui/bluemoon/button.reel/button.css create mode 100644 node_modules/montage/ui/bluemoon/button.reel/button.html create mode 100644 node_modules/montage/ui/bluemoon/button.reel/button.js create mode 100644 node_modules/montage/ui/bluemoon/checkbox.reel/checkbox.css create mode 100644 node_modules/montage/ui/bluemoon/checkbox.reel/checkbox.html create mode 100644 node_modules/montage/ui/bluemoon/checkbox.reel/checkbox.js create mode 100644 node_modules/montage/ui/bluemoon/checkbox.reel/checkmark-dark-disabled.svg create mode 100644 node_modules/montage/ui/bluemoon/checkbox.reel/checkmark-dark.svg create mode 100644 node_modules/montage/ui/bluemoon/checkbox.reel/checkmark-light-disabled.svg create mode 100644 node_modules/montage/ui/bluemoon/checkbox.reel/checkmark.svg create mode 100644 node_modules/montage/ui/bluemoon/progress.reel/progress.css create mode 100644 node_modules/montage/ui/bluemoon/progress.reel/progress.html create mode 100644 node_modules/montage/ui/bluemoon/progress.reel/progress.js create mode 100644 node_modules/montage/ui/bluemoon/progress.reel/rule.png create mode 100644 node_modules/montage/ui/bluemoon/progress.reel/scroll.png create mode 100644 node_modules/montage/ui/bluemoon/slider.reel/slider.css create mode 100644 node_modules/montage/ui/bluemoon/slider.reel/slider.html create mode 100644 node_modules/montage/ui/bluemoon/slider.reel/slider.js create mode 100644 node_modules/montage/ui/bluemoon/textarea.reel/textarea.css create mode 100644 node_modules/montage/ui/bluemoon/textarea.reel/textarea.html create mode 100644 node_modules/montage/ui/bluemoon/textarea.reel/textarea.js create mode 100644 node_modules/montage/ui/bluemoon/textfield.reel/textfield.css create mode 100644 node_modules/montage/ui/bluemoon/textfield.reel/textfield.html create mode 100644 node_modules/montage/ui/bluemoon/textfield.reel/textfield.js create mode 100644 node_modules/montage/ui/bluemoon/toggle.reel/toggle.css create mode 100644 node_modules/montage/ui/bluemoon/toggle.reel/toggle.html create mode 100644 node_modules/montage/ui/bluemoon/toggle.reel/toggle.js delete mode 100755 node_modules/montage/ui/button-group.reel/button-group.css delete mode 100755 node_modules/montage/ui/button-group.reel/button-group.html delete mode 100755 node_modules/montage/ui/button-group.reel/button-group.js delete mode 100755 node_modules/montage/ui/button.reel/button.css delete mode 100755 node_modules/montage/ui/button.reel/button.html mode change 100755 => 100644 node_modules/montage/ui/button.reel/button.js create mode 100644 node_modules/montage/ui/check-input.js delete mode 100755 node_modules/montage/ui/checkbox.reel/checkbox.css delete mode 100755 node_modules/montage/ui/checkbox.reel/checkbox.html mode change 100755 => 100644 node_modules/montage/ui/checkbox.reel/checkbox.js delete mode 100755 node_modules/montage/ui/checkbox.reel/checkmark-dark-disabled.svg delete mode 100755 node_modules/montage/ui/checkbox.reel/checkmark-dark.svg delete mode 100755 node_modules/montage/ui/checkbox.reel/checkmark-light-disabled.svg delete mode 100755 node_modules/montage/ui/checkbox.reel/checkmark.svg create mode 100644 node_modules/montage/ui/composer/composer.js create mode 100644 node_modules/montage/ui/composer/long-press-composer.js create mode 100644 node_modules/montage/ui/composer/swipe-composer.js create mode 100644 node_modules/montage/ui/composer/translate-composer.js create mode 100644 node_modules/montage/ui/date-input.reel/date-input.js delete mode 100644 node_modules/montage/ui/flow-controller.reel/flow-controller.html delete mode 100644 node_modules/montage/ui/flow-controller.reel/flow-controller.js delete mode 100644 node_modules/montage/ui/flow-offset.js delete mode 100644 node_modules/montage/ui/hottext.reel/hottext.css delete mode 100644 node_modules/montage/ui/hottext.reel/hottext.html delete mode 100644 node_modules/montage/ui/hottext.reel/hottext.js delete mode 100644 node_modules/montage/ui/hottextunit.reel/hottextunit.css delete mode 100644 node_modules/montage/ui/hottextunit.reel/hottextunit.html delete mode 100644 node_modules/montage/ui/hottextunit.reel/hottextunit.js mode change 100644 => 100755 node_modules/montage/ui/image.reel/image.js delete mode 100644 node_modules/montage/ui/image2.reel/image2.html delete mode 100644 node_modules/montage/ui/image2.reel/image2.js delete mode 100644 node_modules/montage/ui/image3d.reel/image3d.html delete mode 100644 node_modules/montage/ui/image3d.reel/image3d.js create mode 100644 node_modules/montage/ui/native-control.js create mode 100644 node_modules/montage/ui/number-input.reel/number-input.js delete mode 100755 node_modules/montage/ui/photo-editor.reel/photo-editor.css delete mode 100755 node_modules/montage/ui/photo-editor.reel/photo-editor.html delete mode 100755 node_modules/montage/ui/photo-editor.reel/photo-editor.js create mode 100755 node_modules/montage/ui/radio-button.reel/radio-button.js create mode 100644 node_modules/montage/ui/range-input.reel/range-input.js create mode 100644 node_modules/montage/ui/select-input.reel/select-input.js delete mode 100644 node_modules/montage/ui/slider-base.js delete mode 100755 node_modules/montage/ui/slider.reel/slider.css delete mode 100755 node_modules/montage/ui/slider.reel/slider.html delete mode 100755 node_modules/montage/ui/slider.reel/slider.js create mode 100644 node_modules/montage/ui/text-input.js delete mode 100755 node_modules/montage/ui/textarea.reel/textarea.css delete mode 100755 node_modules/montage/ui/textarea.reel/textarea.html mode change 100755 => 100644 node_modules/montage/ui/textarea.reel/textarea.js delete mode 100755 node_modules/montage/ui/textfield.reel/textfield.css delete mode 100755 node_modules/montage/ui/textfield.reel/textfield.html mode change 100755 => 100644 node_modules/montage/ui/textfield.reel/textfield.js create mode 100644 node_modules/montage/ui/toggle-button.reel/toggle-button.js create mode 100755 node_modules/montage/ui/toggle-switch.reel/toggle-switch.css create mode 100755 node_modules/montage/ui/toggle-switch.reel/toggle-switch.html create mode 100644 node_modules/montage/ui/toggle-switch.reel/toggle-switch.js delete mode 100755 node_modules/montage/ui/toggle.reel/toggle.css delete mode 100755 node_modules/montage/ui/toggle.reel/toggle.html delete mode 100755 node_modules/montage/ui/toggle.reel/toggle.js (limited to 'node_modules') 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 @class module:montage/core/converter/date-converter.DateConverter */ var DateConverter = exports.DateConverter = Montage.create(Converter,/** @lends module:montage/core/converter/date-converter.DateConverter# */ { + /** + Specifies whether the converter allows partial conversion. + @type {Property} + @default {Boolean} true + */ + allowPartialConversion: { + value: false + }, + /** @type {Property} @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 */ 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"); 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, logger = require("core/logger").logger("deserializer"), Promise = require("core/promise").Promise; +// By rebinding eval to a new name, it loses its ability to +// capture the calling scope. +var globalEval = eval; + /** @class module:montage/core/deserializer.Deserializer @extends module:montage/core/core.Montage */ var Deserializer = Montage.create(Montage, /** @lends module:montage/core/deserializer.Deserializer# */ { + _MONTAGE_ID_ATTRIBUTE: {value: "data-montage-id"}, + _objects: {value: null}, /** @private @@ -51,6 +57,13 @@ var Deserializer = Montage.create(Montage, /** @lends module:montage/core/deseri /** @private */ + + /** + @private + */ + // list of ids that were just created for optimization + _optimizedIds: {value: {}}, + _indexedDeserializationUnits: {value: {}}, __sharedDocument: { @@ -365,6 +378,27 @@ var Deserializer = Montage.create(Montage, /** @lends module:montage/core/deseri this._compileAndDeserialize(); return this._compiledDeserializationFunctionString; }}, + + /** + * Optimizes the current serialization for a specific document. + * @function + * @param {Document} doc The document to optimize against, this document can be modified during optimization. + */ + optimizeForDocument: { + value: function(doc) { + var idAttributeName = Deserializer._MONTAGE_ID_ATTRIBUTE, + elements = doc.querySelectorAll('*[' + idAttributeName + ']'), + ids = this._optimizedIds = {}; + + for (var i = 0, element; (element = elements[i]); i++) { + if (!element.id) { + var attribute = element.getAttribute(idAttributeName); + element.setAttribute("id", ids[attribute] = "_" + idAttributeName + "_" + attribute); + } + } + } + }, + /** @private */ @@ -374,9 +408,12 @@ var Deserializer = Montage.create(Montage, /** @lends module:montage/core/deseri exportsStrings = "", unitsStrings = "", objectsStrings = "", + cleanupStrings = "", valueString, exports = {}, modules = this._modules, + idsToRemove = [], + optimizedIds = this._optimizedIds, requireStrings = [], objectNamesCounter = {}, label; @@ -408,8 +445,17 @@ var Deserializer = Montage.create(Montage, /** @lends module:montage/core/deseri } } - 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)"; - //console.log(this._compiledDeserializationFunctionString); + if (idsToRemove.length > 0) { + cleanupStrings = 'element.getElementById("' + idsToRemove.join('").removeAttribute("id");\nelement.getElementById("') + '").removeAttribute("id");'; + for (var i = 0, id; (id = idsToRemove[i]); i++) { + element.getElementById(idsToRemove[i]).removeAttribute("id"); + } + } + + 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)"; + if (logger.isDebug) { + logger.debug(this._compiledDeserializationFunctionString); + } this._serialization = serialization = null; @@ -490,7 +536,7 @@ var Deserializer = Montage.create(Montage, /** @lends module:montage/core/deseri } else if (value === null) { return "null"; } else if ("#" in value) { - type = "elementById"; + type = "elementByMontageId"; value = value["#"]; } else if ("/" in value) { type = "regexp"; @@ -502,7 +548,7 @@ var Deserializer = Montage.create(Montage, /** @lends module:montage/core/deseri type = "function"; value = value["->"]; } else if ("." in value && Object.keys(value).length === 1) { - console.log("Warning: It's not possible to reference elements by class name anymore: " + JSON.stringify(value) + "' in template " + self._origin + "."); + console.log("Warning: It's not possible to reference elements by class name anymore: '" + JSON.stringify(value) + "' in template " + self._origin + "."); } } @@ -529,15 +575,35 @@ var Deserializer = Montage.create(Montage, /** @lends module:montage/core/deseri return '[' + properties.join(",\n") + ']'; break; - case "elementById": - if (deserialize) { - var node = element.getElementById(value); + case "elementByMontageId": + var id = self._optimizedIds[value], + node; + + if (id) { + node = element.getElementById(id); + idsToRemove.push(id); + } else { + node = element.querySelector('*[' + Deserializer._MONTAGE_ID_ATTRIBUTE + '="' + value + '"]'); if (!node) { - console.log("Warning: Element '#" + value + "' not found in template " + self._origin); + node = element.getElementById(value); + id = value; } + } + + if (!node) { + console.log("Warning: Element " + Deserializer._MONTAGE_ID_ATTRIBUTE + "='" + value + "' not found in template " + self._origin); + } + + if (deserialize) { parent[key] = node; } - return 'element.getElementById("' + value + '")'; + + if (id) { + return 'element.getElementById("' + id + '")'; + } else { + // TODO: getElemenyById only here for backwards compatibility + return 'element.querySelector(\'*[' + Deserializer._MONTAGE_ID_ATTRIBUTE + '="' + value + '"]\') || element.getElementById("' + value + '")'; + } break; case "regexp": @@ -569,7 +635,7 @@ var Deserializer = Montage.create(Montage, /** @lends module:montage/core/deseri case "function": var source = "function" + (value.name ? " " + value.name : "") + "(" + value.arguments.join(", ") + ") {\n" + value.body + "\n}"; if (deserialize) { - parent[key] = (1,eval)('(' + source + ')'); + parent[key] = globalEval('(' + source + ')'); } return source; break; @@ -618,7 +684,6 @@ var Deserializer = Montage.create(Montage, /** @lends module:montage/core/deseri // first run, deserialize and create the source of the compiled deserialization function } else { exports = this._compileAndDeserialize(sourceDocument, true); - //console.log(this._compiledDeserializationFunctionString); } if (targetDocument) { @@ -642,6 +707,20 @@ var Deserializer = Montage.create(Montage, /** @lends module:montage/core/deseri } }, + /** + Deserializes a serialization of a single object using a root element to find elements' references. + @function + @param {Element} element The element to be cloned and used during deserialization of elements' references. + @param {function(object)} callback The callback to be invoked when the object has been fully deserialized. + */ + deserializeObjectWithElement: { + value: function(element, callback) { + return this.deserializeWithInstancesAndElementForDocument(null, element, null, function(exports) { + callback(exports ? exports.root : undefined); + }); + } + }, + /** Deserializes all objects. @function @@ -769,9 +848,6 @@ var Deserializer = Montage.create(Montage, /** @lends module:montage/core/deseri for (var unit in serializedUnits) { var unitFunction = units[unit]; if (unitFunction) { - if (serializedUnits[unit].text) { - //debugger; - } unitFunction(object, serializedUnits[unit]); } } diff --git a/node_modules/montage/core/event/binding.js b/node_modules/montage/core/event/binding.js index 0ce154a1..7a15e5b9 100755 --- a/node_modules/montage/core/event/binding.js +++ b/node_modules/montage/core/event/binding.js @@ -88,10 +88,19 @@ Object.defineProperty(ChangeEventDispatchingArray, "splice", { removedMembers = this._splice.apply(this, arguments); removedCount = removedMembers.length; - // I stopped caring about whether or not this splice could be considered an ADDITION or REMOVAL - // all splices result in a modification now; we could change this if we want to + netChange = addedCount - removedCount; + + // Find the most accurate propertyChange type for this splice, + // For the most part it's considered a modification unless the length of the array was modified + // if only to not bother notifying listeners for changes of the length of this array changeType = ChangeTypes.MODIFICATION; + if (netChange > 0) { + changeType = ChangeTypes.ADDITION; + } else if (netChange < 0) { + changeType = ChangeTypes.REMOVAL; + } + if (this.dispatchChangeEvent) { changeEvent = new ChangeEventConstructor(); changeEvent.minus = removedMembers; @@ -103,8 +112,6 @@ Object.defineProperty(ChangeEventDispatchingArray, "splice", { if (this.dispatchChangeAtIndexEvent) { - netChange = addedCount - removedCount; - if (typeof howMany === "undefined") { // no howMany argument given: remove all elements after index? // TODO this may only be in some implementations @@ -498,7 +505,7 @@ var PropertyChangeBindingListener = exports.PropertyChangeBindingListener = Obje localPrevValue = event.minus, localTarget = event.target, type = event.type, - changeType = event.propertyChange, //MODIFICATION is 1, ADDITION 2, REMOVAL 3, + changeType = event.propertyChange, localPropertyName = event.propertyName, boundObjectValue, sourceObjectValue, @@ -508,7 +515,12 @@ var PropertyChangeBindingListener = exports.PropertyChangeBindingListener = Obje baseType, bindingDescriptor, bindingOrigin = this.bindingOrigin, - leftOriginated; + leftOriginated, + changeOriginPropertyPath = null, + exploredPath, + remainingPath, + i, + localPrevValueCount; if (target !== bindingOrigin) { //the left and the right are different objects; easy enough @@ -617,51 +629,46 @@ var PropertyChangeBindingListener = exports.PropertyChangeBindingListener = Obje event.plus = localNewValue; event.target = localTarget; + if (localPrevValue) { - // Now we know that we handled a particular type of change event - // Depending on what happened we may need to remove listeners from a broken propertyPath or - // install listeners along the modified (or deeper) propertyPath - - // MODIFICATION 1 - if (changeType === 1) { - - if (localPrevValue) { - // TODO remove all the listeners from the localPrev object as far to tne end of the path as possible - // localPrevValue.removeEventListener(baseType, this, this.useCapture); - } - - if (localNewValue) { - // TODO this may be less efficient than we could be, but frankly I don't know how to tell where - // in the path you are by the time you get here, so I'm not sure how to install just the part - // we need, plus addEventListener seems to use the targetPropertyPath from the listener - // regardless of what you pass in fro the eventType. - this.target.addEventListener(baseType + "@" + this.targetPropertyPath, this, this.useCapture); - } + // Determine where along the property path the change originated from so we know how to build the path + // to stop observing on things that were removed + //TODO extract this into a "obj.getPathOfObjectAlongPropertyPath" method or something with proper tests + exploredPath = ""; + this.target.getProperty(this.targetPropertyPath, null, null, function(value, currentPathComponent, result) { - } - //ADDITION 2, REMOVAL 3, typically on collections + if (changeOriginPropertyPath) { + return; + } - //TODO looks like we end up wanting to do the sam thing in both cases right now, I think the TODO in the - // modification explains why a bit. - else { + exploredPath += "." + currentPathComponent; - if (localPrevValue) { + if (result === event.target) { + changeOriginPropertyPath = exploredPath.replace(/^\./, ""); + } + }); - // TODO how do we know the nextPathComponent, we need to know the rest of the path after each - // entry in the localPrevValue array -// for (var i = 0; i < localPrevValue.length; i++) { - localPrevValue.removeEventListener(nextPathComponent ? baseType + "@" + nextPathComponent : baseType, this, this.useCapture); -// } + if (changeOriginPropertyPath) { + remainingPath = this.targetPropertyPath.replace(new RegExp("^" + changeOriginPropertyPath + "\.?"), ""); + } else { + remainingPath = this.targetPropertyPath; } - if (localNewValue) { - this.target.addEventListener(baseType + "@" + this.targetPropertyPath, this, this.useCapture); - } else if (event._event.plus) { - this.target.addEventListener(baseType + "@" + this.targetPropertyPath, this, this.useCapture); + // NOTE this check works around Safari not having a removeEventListener on its CanvasPixelArray + // TODO investigate if this is an appropriate fix or not + if (typeof localPrevValue.removeEventListener === "function") { + localPrevValue.removeEventListener(baseType + "@" + remainingPath, this, this.useCapture); } + } - + if (localNewValue) { + // Reinstall listeners along the entire propertyPath from the target + this.target.addEventListener(baseType + "@" + this.targetPropertyPath, this, this.useCapture); + } else if (event._event.plus) { + // TODO removing this causes no spec failures; looks suspicious + this.target.addEventListener(baseType + "@" + this.targetPropertyPath, this, this.useCapture); } + } targetPropertyPath = null; target = null; @@ -964,7 +971,7 @@ Object.defineProperty(Object.prototype, "addEventListener", { anEvent.initCustomEvent("change@" + setter.property, true, false, null); anEvent.minus = prevValue; anEvent.plus = acceptedValue; - anEvent.propertyChange = 1;//MODIFICATION, ADDITION, REMOVAL + anEvent.propertyChange = ChangeTypes.MODIFICATION; anEvent.propertyName = setter.property; this.dispatchEvent(anEvent); } @@ -1041,7 +1048,7 @@ Object.defineProperty(Object.prototype, "addEventListener", { anEvent.initCustomEvent("change@" + setter.property, true, false, null); anEvent.minus = prevValue; anEvent.plus = acceptedValue; - anEvent.propertyChange = 1;//MODIFICATION, ADDITION, REMOVAL + anEvent.propertyChange = ChangeTypes.MODIFICATION; anEvent.propertyName = setter.property; this.dispatchEvent(anEvent); } diff --git a/node_modules/montage/core/event/event-manager.js b/node_modules/montage/core/event/event-manager.js index abc441c8..4adc3926 100755 --- a/node_modules/montage/core/event/event-manager.js +++ b/node_modules/montage/core/event/event-manager.js @@ -24,6 +24,9 @@ var Montage = require("montage").Montage, Deserializer = require("core/deserializer").Deserializer, defaultEventManager; +// XXX Does not presently function server-side +if (typeof window !== "undefined") { // client-side + /* This is to handle browsers that have TouchEvents but don't have the global constructor function Touch */ //if(TouchEvent && typeof window.Touch === "undefined") { // HACK: The commented expression fails because Chrome on the desktop also has TouchEvent and in the code we're either registering touch events OR mouse events on most components. @@ -91,12 +94,12 @@ var EventListenerDescriptor = Montage.create(Montage, { serializable: true, value: null }, - + listener: { serializable: "reference", value: null }, - + capture: { serializable: true, value: null @@ -111,19 +114,19 @@ Serializer.defineSerializationUnit("listeners", function(object) { descriptor, listenerDescriptor, listener; - + for (var type in eventManager.registeredEventListeners) { descriptors = eventManager.registeredEventListeners[type]; descriptor = descriptors && descriptors[uuid]; if (descriptor) { for (var listenerUuid in descriptor.listeners) { listener = descriptor.listeners[listenerUuid]; - + eventListenerDescriptor = EventListenerDescriptor.create(); eventListenerDescriptor.type = type; eventListenerDescriptor.listener = listener.listener; eventListenerDescriptor.capture = listener.capture; - + eventListenerDescriptors.push(eventListenerDescriptor); } } @@ -2073,3 +2076,5 @@ if (typeof window.ondragstart !== undefined) { }; } +} // client-side + diff --git a/node_modules/montage/core/event/mutable-event.js b/node_modules/montage/core/event/mutable-event.js index edf56951..f94ee0b9 100755 --- a/node_modules/montage/core/event/mutable-event.js +++ b/node_modules/montage/core/event/mutable-event.js @@ -11,6 +11,9 @@ var Montage = require("montage").Montage, Enum = require("core/enum").Enum; +// XXX Does not presently function server-side +if (typeof window !== "undefined") { + var ChangeTypes = exports.ChangeTypes = Enum.create().initWithMembers("MODIFICATION", "ADDITION", "REMOVAL"); var _eventConstructorsByType = {}; @@ -232,3 +235,5 @@ _changeEventConstructor.prototype = MutableEvent.create()._initPrototypeWithEven */ _changeEventConstructor.prototype.type = "change"; exports._Change = _changeEventConstructor; + +} // client-side diff --git a/node_modules/montage/core/jshint.js b/node_modules/montage/core/jshint.js index 584b5aef..24f18522 100755 --- a/node_modules/montage/core/jshint.js +++ b/node_modules/montage/core/jshint.js @@ -3928,7 +3928,7 @@ var JSHINT = (function (setup) { JSHINT.edition = '2011-04-16'; - return itself; + return itself; }); // Make JSHINT a CommonJS module, if possible. diff --git a/node_modules/montage/core/logger.js b/node_modules/montage/core/logger.js index 4b0e8233..6f90fab3 100755 --- a/node_modules/montage/core/logger.js +++ b/node_modules/montage/core/logger.js @@ -15,7 +15,8 @@ var Montage = require("montage").Montage, emptyLoggerFunction, getFunctionName, toTimeString, - LoggerUI; + LoggerUI, + localStorage; loggers = exports.loggers = {}; @@ -104,7 +105,7 @@ Logger = exports.Logger = Montage.create(Montage,/** @lends module:montage/core/ value: function(name, dontStoreState) { this.name = name; this._storeState = !dontStoreState; - if (this._storeState) { + if (this._storeState && localStorage) { var storedState = localStorage.getItem("_montage_logger_" + name); if (storedState) { this.isDebug = storedState === "true"; @@ -335,7 +336,7 @@ LoggerUI = Montage.create(Montage, /** @lends module:montage/core/logger.LoggerU name = event.target.value, logger = loggers[name]; logger.isDebug = value; - if (logger._storeState) { + if (logger._storeState && localStorage) { localStorage.setItem("_montage_logger_" + name, value); } } @@ -394,7 +395,7 @@ LoggerUI = Montage.create(Montage, /** @lends module:montage/core/logger.LoggerU input.type = "checkbox"; input.checked = !!iLogger.isDebug; storageKey = "_montage_logger_" + iLogger.name; - if (iLogger._storeState) { + if (iLogger._storeState && localStorage) { storedValue = localStorage.getItem(storageKey); if (storedValue == null) { localStorage.setItem(storageKey, iLogger.isDebug); @@ -485,9 +486,12 @@ var setupUI = function() { @type {Statement} @default window */ -if (window) { +if (typeof window !== "undefined") { + // assigning to a local allows us to feature-test without typeof + localStorage = window.localStorage; window.loggers = loggers; if (window.localStorage) { setupUI(); } } + diff --git a/node_modules/montage/core/next-tick.js b/node_modules/montage/core/next-tick.js new file mode 100644 index 00000000..0c3e209a --- /dev/null +++ b/node_modules/montage/core/next-tick.js @@ -0,0 +1,91 @@ +/* + This file contains proprietary software owned by Motorola Mobility, Inc.
+ No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+ (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. +
*/ + +/** + Defines [nextTick()]{#link nextTick} + @see nextTick + @module montage/core/next-tick +*/ + +/** + @function + @name nextTick +*/ + +(function (definition) { + if (typeof bootstrap !== "undefined") { + bootstrap("core/next-tick", definition); + } else if (typeof require !== "undefined") { + definition(require, exports, module); + } else { + definition({}, {}, {}); + } +})(function (require, exports, module) { + +var nextTick; +// Node implementation: +if (typeof process !== "undefined") { + nextTick = process.nextTick; +// Browser implementation: based on MessageChannel, setImmediate, or setTimeout +} else { + + // queue of tasks implemented as a singly linked list with a head node + var head = {}, tail = head; + // whether a task is pending is represented by the existence of head.next + + nextTick = function (task) { + var alreadyPending = head.next; + tail = tail.next = {task: task}; + if (!alreadyPending) { + // setImmediate, + // postMessage, or + // setTimeout: + request(flush, 0); + } + } + + var flush = function () { + try { + // unroll all pending events + while (head.next) { + head = head.next; + // guarantee consistent queue state + // before task, because it may throw + head.task(); // may throw + } + } finally { + // if a task throws an exception and + // there are more pending tasks, dispatch + // another event + if (head.next) { + // setImmediate, + // postMessage, or + // setTimeout: + request(flush, 0); + } + } + }; + + var request; // must always be called like request(flush, 0); + // in order of desirability: + if (typeof setImmediate !== "undefined") { + request = setImmediate; + } else if (typeof MessageChannel !== "undefined") { + // http://www.nonblocking.io/2011/06/windownexttick.html + var channel = new MessageChannel(); + channel.port1.onmessage = flush; + request = function (flush, zero) { + channel.port2.postMessage(0); + }; + } else { + request = setTimeout; + } + +} + +exports.nextTick = nextTick; + +}); diff --git a/node_modules/montage/core/promise.js b/node_modules/montage/core/promise.js index 80c63943..aabe113d 100755 --- a/node_modules/montage/core/promise.js +++ b/node_modules/montage/core/promise.js @@ -5,7 +5,7 @@ */ // Scope: -// * ES5, W3C setImmediate (shimmed if necessary) +// * ES5 // * speed and economy of memory before safety and securability // * run-time compatibility via thenability @@ -30,13 +30,15 @@ "use strict"; +var TIMER; try { // bootstrapping can't handle relative identifiers - require("core/shim/timers"); // setImmediate + TIMER = require("core/next-tick"); } catch (exception) { // in this case, node can't handle absolute identifiers - require("./shim/timers"); // setImmediate + TIMER = require("./next-tick"); } +var nextTick = TIMER.nextTick; // merely ensures that the returned value can respond to // messages; does not guarantee a full promise API @@ -107,17 +109,10 @@ var PrimordialPromise = Creatable.create({ value: function (descriptor, promiseDescriptor) { // automatically subcreate each of the contained promise types - var creation = Object.create(this, { - DeferredPromise: { - value: this.DeferredPromise.create(promiseDescriptor) - }, - FulfilledPromise: { - value: this.FulfilledPromise.create(promiseDescriptor) - }, - RejectedPromise: { - value: this.RejectedPromise.create(promiseDescriptor) - } - }); + var creation = Object.create(this); + creation.DeferredPromise = this.DeferredPromise.create(promiseDescriptor); + creation.FulfilledPromise = this.FulfilledPromise.create(promiseDescriptor); + creation.RejectedPromise = this.RejectedPromise.create(promiseDescriptor); if (descriptor) { Object.defineProperties(creation, descriptor); @@ -125,17 +120,13 @@ var PrimordialPromise = Creatable.create({ // create static reflections of all new promise methods if (promiseDescriptor) { - var statics = {}; Object.keys(promiseDescriptor).forEach(function (name) { - statics[name] = { - value: function (value) { - var args = Array.prototype.slice.call(arguments, 1); - var promise = this.ref(value); - return promise[name].apply(promise, args); - } + creation[name] = function (value) { + var args = Array.prototype.slice.call(arguments, 1); + var promise = this.ref(value); + return promise[name].apply(promise, args); }; }); - Object.defineProperties(creation, statics); } return creation; @@ -182,15 +173,10 @@ var PrimordialPromise = Creatable.create({ fulfill: { value: function (value) { - return this.FulfilledPromise.create({ - _value: { - value: value, - writable: true - }, - Promise: { - value: this - } - }); + var self = Object.create(this.FulfilledPromise); + self._value = value; + self.Promise = this; + return self; } }, @@ -246,17 +232,10 @@ var PrimordialPromise = Creatable.create({ reject: { value: function (reason, error) { - var self = this.RejectedPromise.create({ - _reason: { - value: reason - }, - _error: { - value: error - }, - Promise: { - value: this - } - }); + var self = Object.create(this.RejectedPromise); + self._reason = reason; + self._error = error; + self.Promise = this; errors.push(error && error.stack || self); return self; } @@ -310,31 +289,13 @@ var PrimordialPromise = Creatable.create({ defer: { value: function () { var deferred; - var promise = this.DeferredPromise.create({ - _pending: { - value: [], - writable: true - }, - _value: { - value: undefined, - writable: true - }, - Promise: { - value: this - } - }); - deferred = this.Deferred.create({ - promise: { - value: promise, - enumerable: true - }, - Promise: { - value: this - } - }); - Object.defineProperty(promise, "_deferred", { - value: deferred - }); + var promise = Object.create(this.DeferredPromise); + promise._pending = []; + promise.Promise = this; + deferred = Object.create(this.Deferred); + deferred.promise = promise; + deferred.Promise = this; + promise._deferred = deferred; return deferred; } }, @@ -349,7 +310,7 @@ var PrimordialPromise = Creatable.create({ } this.promise._value = value = toPromise(value); this.promise._pending.forEach(function (pending) { - setImmediate(function () { + nextTick(function () { value.sendPromise.apply(value, pending); }); }); @@ -380,7 +341,7 @@ var PrimordialPromise = Creatable.create({ } else { var args = arguments, value = this._value; - setImmediate(function () { + nextTick(function () { value.sendPromise.apply(value, args); }); } @@ -415,6 +376,14 @@ var Promise = PrimordialPromise.create({}, { // Descriptor for each of the three } }, + spread: { + value: function (fulfilled, rejected) { + return this.all().then(function (args) { + return fulfilled.apply(void 0, args); + }, rejected); + } + }, + then: { value: function (fulfilled, rejected) { var self = this; @@ -425,7 +394,7 @@ var Promise = PrimordialPromise.create({}, { // Descriptor for each of the three try { deferred.resolve(fulfilled ? fulfilled(value) : value); } catch (error) { - console.log(error.stack); + console.error(error.stack); deferred.reject(error.message, error); } } @@ -445,7 +414,7 @@ var Promise = PrimordialPromise.create({}, { // Descriptor for each of the three } } - setImmediate(function () { + nextTick(function () { self.sendPromise( function (value) { if (done) { @@ -478,7 +447,7 @@ var Promise = PrimordialPromise.create({}, { // Descriptor for each of the three value: function (name, args) { var deferred = Promise.defer(); var self = this; - setImmediate(function () { + nextTick(function () { self.sendPromise.apply( self, [ @@ -632,7 +601,7 @@ var Promise = PrimordialPromise.create({}, { // Descriptor for each of the three this.then(void 0, function (reason, error) { // forward to a future turn so that ``when`` // does not catch it and turn it into a rejection. - setImmediate(function () { + nextTick(function () { console.error(error && error.stack || error || reason); throw error; }); diff --git a/node_modules/montage/core/serializer.js b/node_modules/montage/core/serializer.js index 129c3e80..449ebf7d 100755 --- a/node_modules/montage/core/serializer.js +++ b/node_modules/montage/core/serializer.js @@ -12,6 +12,14 @@ var Montage = require("montage").Montage; var Uuid = require("core/uuid").Uuid; var Deserializer = require("core/deserializer").Deserializer; +var logger = require("core/logger").logger("serializer"); +var Element; + +// Shadowing the global with a local allows us to feature-test without typeof +// Element does not exist on the server-side +if (typeof window !== "undefined") { + Element = window.Element; +} /** @class module:montage/core/serializer.Serializer @@ -19,6 +27,7 @@ var Deserializer = require("core/deserializer").Deserializer; @extends module:montage/core/core.Montage */ var Serializer = Montage.create(Montage, /** @lends module:montage/serializer.Serializer# */ { + _MONTAGE_ID_ATTRIBUTE: {value: "data-montage-id"}, _serializedObjects: {value: {}}, // uuid -> string _serializedReferences: {value: {}}, // uuid -> string _externalObjects: {value: null}, // label -> object @@ -358,7 +367,7 @@ var Serializer = Montage.create(Montage, /** @lends module:montage/serializer.Se if (value instanceof RegExp) { return this._serializeRegExp(value); } else if (value && (typeof value === "object" || typeof value === "function")) { - if (value instanceof Element) { + if (Element && value instanceof Element) { return this._serializeElement(value); } else if (Array.isArray(value)) { return this._serializeArray(value, indent + 1); @@ -378,11 +387,15 @@ var Serializer = Montage.create(Montage, /** @lends module:montage/serializer.Se @private */ _serializeElement: {value: function(element) { - if (element.id) { + var attribute = element.getAttribute(this._MONTAGE_ID_ATTRIBUTE), + // TODO: element.id only here for backwards compatibility + id = attribute || element.id; + + if (id) { this._externalElements.push(element); - return '{"#":"' + element.id + '"}'; + return '{"#":"' + id + '"}'; } else { - throw "Error: Not possible to serialize a DOM element with no id assigned: " + element.outerHTML; + logger.error("Error: Not possible to serialize a DOM element with no id assigned: " + element.outerHTML); } }}, diff --git a/node_modules/montage/core/shim.js b/node_modules/montage/core/shim.js index 18aa0233..e6c1a097 100755 --- a/node_modules/montage/core/shim.js +++ b/node_modules/montage/core/shim.js @@ -7,8 +7,6 @@ @module montage/core/shim @requires montage/core/shim/string @requires montage/core/shim/array - @requires montage/core/shim/timers */ require("./shim/string"); require("./shim/array"); -require("./shim/timers"); \ No newline at end of file diff --git a/node_modules/montage/core/shim/immediate.js b/node_modules/montage/core/shim/immediate.js new file mode 100644 index 00000000..3ac48f31 --- /dev/null +++ b/node_modules/montage/core/shim/immediate.js @@ -0,0 +1,57 @@ +/* + This file contains proprietary software owned by Motorola Mobility, Inc.
+ No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+ (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. +
*/ + +/** + [setImmediate()]{@link setImmediate} + and [clearImmediate()]{@link clearImmediate} shim functions. + @see setImmediate + @see clearImmediate + @module montage/core/shim/immediate +*/ + +/** + @function + @name setImmediate + @global +*/ + +/** + @function + @name clearImmediate + @global +*/ + +(function (global) { + +var nextTick = require("../next-tick").nextTick; + +if (typeof setImmediate === "undefined") { + + var nextHandle = 0; + var handles = {}; + + global.setImmediate = function setImmediate(callback) { + var handle = nextHandle++; + var args = arguments.length > 1 ? + Array.prototype.slice.call(arguments, 1) : + void 0; + handles[handle] = true; + nextTick(function () { + if (handles[handle]) { + callback.apply(void 0, args); + delete handles[handle]; + } + }); + return handle; + }; + + global.clearImmediate = function clearImmediate(handle) { + delete handles[handle]; + }; + +} + +})(typeof global === "undefined" ? window : global); diff --git a/node_modules/montage/core/shim/structures.js b/node_modules/montage/core/shim/structures.js index 2f3d7d05..fb8e2191 100755 --- a/node_modules/montage/core/shim/structures.js +++ b/node_modules/montage/core/shim/structures.js @@ -17,9 +17,9 @@ @classdesc Provides a Map data structure for managing key/value pairs, including methods for querying and manipulating map elements. A map cannot contain duplicate keys; each key can map to at most one value. */ exports.Map = Map; -function Map(ignored, options) { +function Map(reserved, options) { if (!(this instanceof Map)) { - return new Map(ignored, options); + return new Map(reserved, options); } options = options || {}; var eq = options.eq || Set.eq; @@ -131,9 +131,9 @@ Object.defineProperties(Map.prototype, /** @lends module:montage/core/shim/struc @class module:montage/core/shim/structures.Set */ exports.Set = Set; -function Set(ignored, options) { +function Set(reserved, options) { if (!(this instanceof Set)) { - return new Set(ignored, options); + return new Set(reserved, options); } options = options || {}; var eq = options.eq || Set.eq; @@ -238,13 +238,13 @@ Object.defineProperties(Set.prototype, /** @lends module:montage/core/shim/struc }); /** @class module:montage/core/shim/structures.OrderedSet - @param {boolean} ignored + @param {boolean} reserved @param {object} options */ exports.OrderedSet = OrderedSet; -function OrderedSet(ignored, options) { +function OrderedSet(reserved, options) { if (!(this instanceof OrderedSet)) { - return new OrderedSet(ignored, options); + return new OrderedSet(reserved, options); } options = options || {}; var eq = options.eq || OrderedSet.eq; @@ -397,14 +397,14 @@ Set.hash = function (value) { /** @exports CacheMap @function - @param {Boolean} ignored + @param {Boolean} reserved @param {String} options - @returns new CacheMap(ignored, options) + @returns new CacheMap(reserved, options) */ exports.CacheMap = CacheMap; -function CacheMap(ignored, options) { +function CacheMap(reserved, options) { if (!(this instanceof CacheMap)) { - return new CacheMap(ignored, options); + return new CacheMap(reserved, options); } options = options || {}; diff --git a/node_modules/montage/core/shim/timers.js b/node_modules/montage/core/shim/timers.js deleted file mode 100755 index 859a7aec..00000000 --- a/node_modules/montage/core/shim/timers.js +++ /dev/null @@ -1,87 +0,0 @@ -/* - This file contains proprietary software owned by Motorola Mobility, Inc.
- No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
- (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. -
*/ - - /** - Defines [setImmediate()]{@link setImmediate} and [clearImmediate()]{@link clearImmediate} shim functions. - @see setImmediate - @see clearImmediate - @module montage/core/shim/timers - */ - -/** - @function - @name setImmediate - @global -*/ - -/** - @function - @name clearImmediate - @global -*/ - -(function (global) { - -var nextTick; -if (typeof process !== "undefined") { - nextTick = process.nextTick; -} else if (typeof MessageChannel !== "undefined") { - // http://www.nonblocking.io/2011/06/windownexttick.html - var channel = new MessageChannel(); - // linked list of tasks (single, with head node) - var head = {}, tail = head; - - channel.port1.onmessage = function () { - var next = head.next; - var task = next.task; - head = next; - task(); - }; - - nextTick = function (task) { - tail = tail.next = {task: task}; - channel.port2.postMessage(void 0); - } -} else if (typeof setTimeout !== "undefined") { - - nextTick = function (callback) { - setTimeout(callback, 0); - }; -} else { - throw new Error("Can't shim setImmediate."); -} - -if (typeof setImmediate === "undefined") { - var nextHandle = 0; - var handles = {}; - - - global.setImmediate = function setImmediate(callback) { - var handle = nextHa