dist/ember.js in ember-source-1.9.0.beta.1 vs dist/ember.js in ember-source-1.9.0.beta.1.1

- old
+ new

@@ -638,15 +638,14 @@ enifed("backburner/deferred-action-queues", ["./utils","./queue","exports"], function(__dependency1__, __dependency2__, __exports__) { "use strict"; var each = __dependency1__.each; - var isString = __dependency1__.isString; var Queue = __dependency2__["default"]; function DeferredActionQueues(queueNames, options) { - var queues = this.queues = {}; + var queues = this.queues = Object.create(null); this.queueNames = queueNames = queueNames || []; this.options = options; each(queueNames, function(queueName) { @@ -661,125 +660,45 @@ DeferredActionQueues.prototype = { schedule: function(name, target, method, args, onceFlag, stack) { var queues = this.queues; var queue = queues[name]; - if (!queue) { noSuchQueue(name); } + if (!queue) { + noSuchQueue(name); + } if (onceFlag) { return queue.pushUnique(target, method, args, stack); } else { return queue.push(target, method, args, stack); } }, - invoke: function(target, method, args, _, _errorRecordedForStack) { - if (args && args.length > 0) { - method.apply(target, args); - } else { - method.call(target); - } - }, - - invokeWithOnError: function(target, method, args, onError, errorRecordedForStack) { - try { - if (args && args.length > 0) { - method.apply(target, args); - } else { - method.call(target); - } - } catch(error) { - onError(error, errorRecordedForStack); - } - }, - flush: function() { var queues = this.queues; var queueNames = this.queueNames; var queueName, queue, queueItems, priorQueueNameIndex; var queueNameIndex = 0; var numberOfQueues = queueNames.length; var options = this.options; - var onError = options.onError || (options.onErrorTarget && options.onErrorTarget[options.onErrorMethod]); - var invoke = onError ? this.invokeWithOnError : this.invoke; while (queueNameIndex < numberOfQueues) { queueName = queueNames[queueNameIndex]; queue = queues[queueName]; - queueItems = queue._queueBeingFlushed = queue._queue.slice(); - queue._queue = []; - queue.targetQueues = Object.create(null); - var queueOptions = queue.options; // TODO: write a test for this - var before = queueOptions && queueOptions.before; - var after = queueOptions && queueOptions.after; - var target, method, args, errorRecordedForStack; - var queueIndex = 0; - var numberOfQueueItems = queueItems.length; + var numberOfQueueItems = queue._queue.length; - if (numberOfQueueItems && before) { - before(); - } - - while (queueIndex < numberOfQueueItems) { - target = queueItems[queueIndex]; - method = queueItems[queueIndex+1]; - args = queueItems[queueIndex+2]; - errorRecordedForStack = queueItems[queueIndex+3]; // Debugging assistance - - // - - if (isString(method)) { - method = target[method]; - } - - // method could have been nullified / canceled during flush - if (method) { - // - // ** Attention intrepid developer ** - // - // To find out the stack of this task when it was scheduled onto - // the run loop, add the following to your app.js: - // - // Ember.run.backburner.DEBUG = true; // NOTE: This slows your app, don't leave it on in production. - // - // Once that is in place, when you are at a breakpoint and navigate - // here in the stack explorer, you can look at `errorRecordedForStack.stack`, - // which will be the captured stack when this job was scheduled. - // - invoke(target, method, args, onError, errorRecordedForStack); - } - - queueIndex += 4; - } - - queue._queueBeingFlushed = null; - if (numberOfQueueItems && after) { - after(); - } - - if ((priorQueueNameIndex = indexOfPriorQueueWithActions(this, queueNameIndex)) !== -1) { - queueNameIndex = priorQueueNameIndex; - } else { + if (numberOfQueueItems === 0) { queueNameIndex++; + } else { + queue.flush(false /* async */); + queueNameIndex = 0; } } } }; - function indexOfPriorQueueWithActions(daq, currentQueueIndex) { - var queueName, queue; - - for (var i = 0, l = currentQueueIndex; i <= l; i++) { - queueName = daq.queueNames[i]; - queue = daq.queues[queueName]; - if (queue._queue.length) { return i; } - } - - return -1; - } - __exports__["default"] = DeferredActionQueues; }); enifed("backburner/platform", ["exports"], function(__exports__) { @@ -793,13 +712,15 @@ return !!e; })(); __exports__.needsIETryCatchFix = needsIETryCatchFix; }); enifed("backburner/queue", - ["exports"], - function(__exports__) { + ["./utils","exports"], + function(__dependency1__, __exports__) { "use strict"; + var isString = __dependency1__.isString; + function Queue(name, options, globalOptions) { this.name = name; this.globalOptions = globalOptions || {}; this.options = options; this._queue = []; @@ -893,61 +814,94 @@ target: target, method: method }; }, - // TODO: remove me, only being used for Ember.run.sync - flush: function() { + invoke: function(target, method, args, _, _errorRecordedForStack) { + if (args && args.length > 0) { + method.apply(target, args); + } else { + method.call(target); + } + }, + + invokeWithOnError: function(target, method, args, onError, errorRecordedForStack) { + try { + if (args && args.length > 0) { + method.apply(target, args); + } else { + method.call(target); + } + } catch(error) { + onError(error, errorRecordedForStack); + } + }, + + flush: function(sync) { var queue = this._queue; + var length = queue.length; + + if (length === 0) { + return; + } + var globalOptions = this.globalOptions; var options = this.options; var before = options && options.before; var after = options && options.after; - var onError = globalOptions.onError || (globalOptions.onErrorTarget && globalOptions.onErrorTarget[globalOptions.onErrorMethod]); - var target, method, args, stack, i, l = queue.length; + var onError = globalOptions.onError || (globalOptions.onErrorTarget && + globalOptions.onErrorTarget[globalOptions.onErrorMethod]); + var target, method, args, errorRecordedForStack; + var invoke = onError ? this.invokeWithOnError : this.invoke; this.targetQueues = Object.create(null); + var queueItems = this._queueBeingFlushed = this._queue.slice(); + this._queue = []; - if (l && before) { before(); } - for (i = 0; i < l; i += 4) { - target = queue[i]; - method = queue[i+1]; - args = queue[i+2]; - stack = queue[i+3]; // Debugging assistance + if (before) { + before(); + } - // TODO: error handling - if (args && args.length > 0) { - if (onError) { - try { - method.apply(target, args); - } catch (e) { - onError(e); - } - } else { - method.apply(target, args); - } - } else { - if (onError) { - try { - method.call(target); - } catch(e) { - onError(e); - } - } else { - method.call(target); - } + for (var i = 0; i < length; i += 4) { + target = queueItems[i]; + method = queueItems[i+1]; + args = queueItems[i+2]; + errorRecordedForStack = queueItems[i+3]; // Debugging assistance + + if (isString(method)) { + method = target[method]; } + + // method could have been nullified / canceled during flush + if (method) { + // + // ** Attention intrepid developer ** + // + // To find out the stack of this task when it was scheduled onto + // the run loop, add the following to your app.js: + // + // Ember.run.backburner.DEBUG = true; // NOTE: This slows your app, don't leave it on in production. + // + // Once that is in place, when you are at a breakpoint and navigate + // here in the stack explorer, you can look at `errorRecordedForStack.stack`, + // which will be the captured stack when this job was scheduled. + // + invoke(target, method, args, onError, errorRecordedForStack); + } } - if (l && after) { after(); } - // check if new items have been added - if (queue.length > l) { - this._queue = queue.slice(l); - this.flush(); - } else { - this._queue.length = 0; + if (after) { + after(); } + + this._queueBeingFlushed = undefined; + + if (sync !== false && + this._queue.length > 0) { + // check if new items have been added + this.flush(true); + } }, cancel: function(actionToCancel) { var queue = this._queue, currentTarget, currentMethod, i, l; var target = actionToCancel.target; @@ -978,13 +932,15 @@ } // if not found in current queue // could be in the queue that is being flushed queue = this._queueBeingFlushed; + if (!queue) { return; } + for (i = 0, l = queue.length; i < l; i += 4) { currentTarget = queue[i]; currentMethod = queue[i+1]; if (currentTarget === target && @@ -6034,61 +5990,45 @@ var Select = View.extend({ instrumentDisplay: 'Ember.Select', tagName: 'select', classNames: ['ember-select'], - defaultTemplate: Ember.Handlebars.template(function (Handlebars,depth0,helpers,partials,data) { - this.compilerInfo = [4,'>= 1.0.0']; - helpers = this.merge(helpers, Ember.Handlebars.helpers); data = data || {}; - var buffer = '', stack1, escapeExpression=this.escapeExpression, self=this; - - function program1(depth0,data) { - - var buffer = '', stack1; + defaultTemplate: Ember.Handlebars.template({"1":function(depth0,helpers,partials,data) { + var stack1, buffer = ''; data.buffer.push("<option value=\"\">"); - stack1 = helpers._triageMustache.call(depth0, "view.prompt", {hash:{},hashTypes:{},hashContexts:{},contexts:[depth0],types:["ID"],data:data}); - if(stack1 || stack1 === 0) { data.buffer.push(stack1); } + stack1 = helpers._triageMustache.call(depth0, "view.prompt", {"name":"_triageMustache","hash":{},"hashTypes":{},"hashContexts":{},"types":["ID"],"contexts":[depth0],"data":data}); + if (stack1 != null) { data.buffer.push(stack1); } data.buffer.push("</option>"); return buffer; - } - - function program3(depth0,data) { - + },"3":function(depth0,helpers,partials,data) { var stack1; - stack1 = helpers.each.call(depth0, "view.groupedContent", {hash:{},hashTypes:{},hashContexts:{},inverse:self.noop,fn:self.program(4, program4, data),contexts:[depth0],types:["ID"],data:data}); - if(stack1 || stack1 === 0) { data.buffer.push(stack1); } + stack1 = helpers.each.call(depth0, "view.groupedContent", {"name":"each","hash":{},"hashTypes":{},"hashContexts":{},"fn":this.program(4, data),"inverse":this.noop,"types":["ID"],"contexts":[depth0],"data":data}); + if (stack1 != null) { data.buffer.push(stack1); } else { data.buffer.push(''); } - } - function program4(depth0,data) { - - - data.buffer.push(escapeExpression(helpers.view.call(depth0, "view.groupView", {hash:{ - 'content': ("content"), - 'label': ("label") - },hashTypes:{'content': "ID",'label': "ID"},hashContexts:{'content': depth0,'label': depth0},contexts:[depth0],types:["ID"],data:data}))); - } - - function program6(depth0,data) { - + },"4":function(depth0,helpers,partials,data) { + var escapeExpression=this.escapeExpression; + data.buffer.push(escapeExpression(helpers.view.call(depth0, "view.groupView", {"name":"view","hash":{ + 'label': ("label"), + 'content': ("content") + },"hashTypes":{'label': "ID",'content': "ID"},"hashContexts":{'label': depth0,'content': depth0},"types":["ID"],"contexts":[depth0],"data":data}))); + },"6":function(depth0,helpers,partials,data) { var stack1; - stack1 = helpers.each.call(depth0, "view.content", {hash:{},hashTypes:{},hashContexts:{},inverse:self.noop,fn:self.program(7, program7, data),contexts:[depth0],types:["ID"],data:data}); - if(stack1 || stack1 === 0) { data.buffer.push(stack1); } + stack1 = helpers.each.call(depth0, "view.content", {"name":"each","hash":{},"hashTypes":{},"hashContexts":{},"fn":this.program(7, data),"inverse":this.noop,"types":["ID"],"contexts":[depth0],"data":data}); + if (stack1 != null) { data.buffer.push(stack1); } else { data.buffer.push(''); } - } - function program7(depth0,data) { - - - data.buffer.push(escapeExpression(helpers.view.call(depth0, "view.optionView", {hash:{ + },"7":function(depth0,helpers,partials,data) { + var escapeExpression=this.escapeExpression; + data.buffer.push(escapeExpression(helpers.view.call(depth0, "view.optionView", {"name":"view","hash":{ 'content': ("") - },hashTypes:{'content': "ID"},hashContexts:{'content': depth0},contexts:[depth0],types:["ID"],data:data}))); - } - - stack1 = helpers['if'].call(depth0, "view.prompt", {hash:{},hashTypes:{},hashContexts:{},inverse:self.noop,fn:self.program(1, program1, data),contexts:[depth0],types:["ID"],data:data}); - if(stack1 || stack1 === 0) { data.buffer.push(stack1); } - stack1 = helpers['if'].call(depth0, "view.optionGroupPath", {hash:{},hashTypes:{},hashContexts:{},inverse:self.program(6, program6, data),fn:self.program(3, program3, data),contexts:[depth0],types:["ID"],data:data}); - if(stack1 || stack1 === 0) { data.buffer.push(stack1); } + },"hashTypes":{'content': "ID"},"hashContexts":{'content': depth0},"types":["ID"],"contexts":[depth0],"data":data}))); + },"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) { + var stack1, buffer = ''; + stack1 = helpers['if'].call(depth0, "view.prompt", {"name":"if","hash":{},"hashTypes":{},"hashContexts":{},"fn":this.program(1, data),"inverse":this.noop,"types":["ID"],"contexts":[depth0],"data":data}); + if (stack1 != null) { data.buffer.push(stack1); } + stack1 = helpers['if'].call(depth0, "view.optionGroupPath", {"name":"if","hash":{},"hashTypes":{},"hashContexts":{},"fn":this.program(3, data),"inverse":this.program(6, data),"types":["ID"],"contexts":[depth0],"data":data}); + if (stack1 != null) { data.buffer.push(stack1); } return buffer; - }), + },"useData":true}), attributeBindings: ['multiple', 'disabled', 'tabindex', 'name', 'required', 'autofocus', 'form', 'size'], /** The `multiple` attribute of the select element. Indicates whether multiple \ No newline at end of file