ember-source 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of ember-source might be problematic. Click here for more details.

@@ -1,5 +1,5 @@
1
- // Version: v1.0.0-rc.1-354-g4e75d2b
2
- // Last commit: 4e75d2b (2013-04-09 16:28:08 -0700)
1
+ // Version: v1.0.0-rc.1-536-gd47406c
2
+ // Last commit: d47406c (2013-04-25 17:21:02 -0700)
3
3
 
4
4
 
5
5
  (function() {
@@ -151,8 +151,8 @@ Ember.deprecateFunc = function(message, func) {
151
151
 
152
152
  })();
153
153
 
154
- // Version: v1.0.0-rc.1-354-g4e75d2b
155
- // Last commit: 4e75d2b (2013-04-09 16:28:08 -0700)
154
+ // Version: v1.0.0-rc.1-536-gd47406c
155
+ // Last commit: d47406c (2013-04-25 17:21:02 -0700)
156
156
 
157
157
 
158
158
  (function() {
@@ -212,7 +212,7 @@ var define, requireModule;
212
212
 
213
213
  @class Ember
214
214
  @static
215
- @version 1.0.0-rc.2
215
+ @version 1.0.0-rc.3
216
216
  */
217
217
 
218
218
  if ('undefined' === typeof Ember) {
@@ -239,10 +239,10 @@ Ember.toString = function() { return "Ember"; };
239
239
  /**
240
240
  @property VERSION
241
241
  @type String
242
- @default '1.0.0-rc.2'
242
+ @default '1.0.0-rc.3'
243
243
  @final
244
244
  */
245
- Ember.VERSION = '1.0.0-rc.2';
245
+ Ember.VERSION = '1.0.0-rc.3';
246
246
 
247
247
  /**
248
248
  Standard environmental variables. You can define these in a global `ENV`
@@ -467,7 +467,7 @@ Ember.none = Ember.deprecateFunc("Ember.none is deprecated. Please use Ember.isN
467
467
  @return {Boolean}
468
468
  */
469
469
  Ember.isEmpty = function(obj) {
470
- return obj === null || obj === undefined || (obj.length === 0 && typeof obj !== 'function') || (typeof obj === 'object' && Ember.get(obj, 'length') === 0);
470
+ return Ember.isNone(obj) || (obj.length === 0 && typeof obj !== 'function') || (typeof obj === 'object' && Ember.get(obj, 'length') === 0);
471
471
  };
472
472
  Ember.empty = Ember.deprecateFunc("Ember.empty is deprecated. Please use Ember.isEmpty instead.", Ember.isEmpty) ;
473
473
 
@@ -500,6 +500,13 @@ var platform = Ember.platform = {};
500
500
  */
501
501
  Ember.create = Object.create;
502
502
 
503
+ // IE8 has Object.create but it couldn't treat property descripters.
504
+ if (Ember.create) {
505
+ if (Ember.create({a: 1}, {a: {value: 2}}).a !== 2) {
506
+ Ember.create = null;
507
+ }
508
+ }
509
+
503
510
  // STUB_OBJECT_CREATE allows us to override other libraries that stub
504
511
  // Object.create different than we would prefer
505
512
  if (!Ember.create || Ember.ENV.STUB_OBJECT_CREATE) {
@@ -634,62 +641,6 @@ if (Ember.ENV.MANDATORY_SETTER && !platform.hasPropertyAccessors) {
634
641
 
635
642
 
636
643
 
637
- (function() {
638
- var utils = Ember.EnumerableUtils = {
639
- map: function(obj, callback, thisArg) {
640
- return obj.map ? obj.map.call(obj, callback, thisArg) : Array.prototype.map.call(obj, callback, thisArg);
641
- },
642
-
643
- forEach: function(obj, callback, thisArg) {
644
- return obj.forEach ? obj.forEach.call(obj, callback, thisArg) : Array.prototype.forEach.call(obj, callback, thisArg);
645
- },
646
-
647
- indexOf: function(obj, element, index) {
648
- return obj.indexOf ? obj.indexOf.call(obj, element, index) : Array.prototype.indexOf.call(obj, element, index);
649
- },
650
-
651
- indexesOf: function(obj, elements) {
652
- return elements === undefined ? [] : utils.map(elements, function(item) {
653
- return utils.indexOf(obj, item);
654
- });
655
- },
656
-
657
- addObject: function(array, item) {
658
- var index = utils.indexOf(array, item);
659
- if (index === -1) { array.push(item); }
660
- },
661
-
662
- removeObject: function(array, item) {
663
- var index = utils.indexOf(array, item);
664
- if (index !== -1) { array.splice(index, 1); }
665
- },
666
-
667
- replace: function(array, idx, amt, objects) {
668
- if (array.replace) {
669
- return array.replace(idx, amt, objects);
670
- } else {
671
- var args = Array.prototype.concat.apply([idx, amt], objects);
672
- return array.splice.apply(array, args);
673
- }
674
- },
675
-
676
- intersection: function(array1, array2) {
677
- var intersection = [];
678
-
679
- array1.forEach(function(element) {
680
- if (array2.indexOf(element) >= 0) {
681
- intersection.push(element);
682
- }
683
- });
684
-
685
- return intersection;
686
- }
687
- };
688
-
689
- })();
690
-
691
-
692
-
693
644
  (function() {
694
645
  /*jshint newcap:false*/
695
646
  /**
@@ -1566,6 +1517,68 @@ Ember.subscribe = Ember.Instrumentation.subscribe;
1566
1517
 
1567
1518
 
1568
1519
 
1520
+ (function() {
1521
+ var map, forEach, indexOf, concat;
1522
+ concat = Array.prototype.concat;
1523
+ map = Array.prototype.map || Ember.ArrayPolyfills.map;
1524
+ forEach = Array.prototype.forEach || Ember.ArrayPolyfills.forEach;
1525
+ indexOf = Array.prototype.indexOf || Ember.ArrayPolyfills.indexOf;
1526
+
1527
+ var utils = Ember.EnumerableUtils = {
1528
+ map: function(obj, callback, thisArg) {
1529
+ return obj.map ? obj.map.call(obj, callback, thisArg) : map.call(obj, callback, thisArg);
1530
+ },
1531
+
1532
+ forEach: function(obj, callback, thisArg) {
1533
+ return obj.forEach ? obj.forEach.call(obj, callback, thisArg) : forEach.call(obj, callback, thisArg);
1534
+ },
1535
+
1536
+ indexOf: function(obj, element, index) {
1537
+ return obj.indexOf ? obj.indexOf.call(obj, element, index) : indexOf.call(obj, element, index);
1538
+ },
1539
+
1540
+ indexesOf: function(obj, elements) {
1541
+ return elements === undefined ? [] : utils.map(elements, function(item) {
1542
+ return utils.indexOf(obj, item);
1543
+ });
1544
+ },
1545
+
1546
+ addObject: function(array, item) {
1547
+ var index = utils.indexOf(array, item);
1548
+ if (index === -1) { array.push(item); }
1549
+ },
1550
+
1551
+ removeObject: function(array, item) {
1552
+ var index = utils.indexOf(array, item);
1553
+ if (index !== -1) { array.splice(index, 1); }
1554
+ },
1555
+
1556
+ replace: function(array, idx, amt, objects) {
1557
+ if (array.replace) {
1558
+ return array.replace(idx, amt, objects);
1559
+ } else {
1560
+ var args = concat.apply([idx, amt], objects);
1561
+ return array.splice.apply(array, args);
1562
+ }
1563
+ },
1564
+
1565
+ intersection: function(array1, array2) {
1566
+ var intersection = [];
1567
+
1568
+ utils.forEach(array1, function(element) {
1569
+ if (utils.indexOf(array2, element) >= 0) {
1570
+ intersection.push(element);
1571
+ }
1572
+ });
1573
+
1574
+ return intersection;
1575
+ }
1576
+ };
1577
+
1578
+ })();
1579
+
1580
+
1581
+
1569
1582
  (function() {
1570
1583
  /**
1571
1584
  @module ember-metal
@@ -1705,7 +1718,7 @@ OrderedSet.prototype = {
1705
1718
  */
1706
1719
  forEach: function(fn, self) {
1707
1720
  // allow mutation during iteration
1708
- var list = this.list.slice();
1721
+ var list = this.toArray();
1709
1722
 
1710
1723
  for (var i = 0, j = list.length; i < j; i++) {
1711
1724
  fn.call(self, list[i]);
@@ -1728,7 +1741,7 @@ OrderedSet.prototype = {
1728
1741
  var set = new OrderedSet();
1729
1742
 
1730
1743
  set.presenceSet = copy(this.presenceSet);
1731
- set.list = this.list.slice();
1744
+ set.list = this.toArray();
1732
1745
 
1733
1746
  return set;
1734
1747
  }
@@ -1811,12 +1824,10 @@ Map.prototype = {
1811
1824
  // to use in browsers that are not ES6 friendly;
1812
1825
  var keys = this.keys,
1813
1826
  values = this.values,
1814
- guid = guidFor(key),
1815
- value;
1827
+ guid = guidFor(key);
1816
1828
 
1817
1829
  if (values.hasOwnProperty(guid)) {
1818
1830
  keys.remove(key);
1819
- value = values[guid];
1820
1831
  delete values[guid];
1821
1832
  return true;
1822
1833
  } else {
@@ -1988,13 +1999,12 @@ get = function get(obj, keyName) {
1988
1999
  obj = null;
1989
2000
  }
1990
2001
 
1991
- if (!obj || keyName.indexOf('.') !== -1) {
1992
- Ember.assert("Cannot call get with '"+ keyName +"' on an undefined object.", obj !== undefined);
2002
+ Ember.assert("Cannot call get with '"+ keyName +"' on an undefined object.", obj !== undefined);
2003
+
2004
+ if (obj === null || keyName.indexOf('.') !== -1) {
1993
2005
  return getPath(obj, keyName);
1994
2006
  }
1995
2007
 
1996
- Ember.assert("You need to provide an object and key to `get`.", !!obj && keyName);
1997
-
1998
2008
  var meta = obj[META_KEY], desc = meta && meta.descs[keyName], ret;
1999
2009
  if (desc) {
2000
2010
  return desc.get(obj, keyName);
@@ -2066,7 +2076,7 @@ var getPath = Ember._getPath = function(root, path) {
2066
2076
 
2067
2077
  parts = path.split(".");
2068
2078
  len = parts.length;
2069
- for (idx=0; root && idx<len; idx++) {
2079
+ for (idx=0; root !== undefined && root !== null && idx<len; idx++) {
2070
2080
  root = get(root, parts[idx], true);
2071
2081
  if (root && root.isDestroyed) { return undefined; }
2072
2082
  }
@@ -2112,7 +2122,9 @@ Ember.getPath = Ember.deprecateFunc('getPath is deprecated since get now support
2112
2122
 
2113
2123
  var o_create = Ember.create,
2114
2124
  metaFor = Ember.meta,
2115
- META_KEY = Ember.META_KEY;
2125
+ META_KEY = Ember.META_KEY,
2126
+ /* listener flags */
2127
+ ONCE = 1, SUSPENDED = 2, IMMEDIATE = 4;
2116
2128
 
2117
2129
  /*
2118
2130
  The event system uses a series of nested hashes to store listeners on an
@@ -2125,7 +2137,7 @@ var o_create = Ember.create,
2125
2137
  {
2126
2138
  listeners: { // variable name: `listenerSet`
2127
2139
  "foo:changed": [ // variable name: `actions`
2128
- [target, method, onceFlag, suspendedFlag]
2140
+ [target, method, flags]
2129
2141
  ]
2130
2142
  }
2131
2143
  }
@@ -2171,12 +2183,11 @@ function actionsUnion(obj, eventName, otherActions) {
2171
2183
  for (var i = actions.length - 1; i >= 0; i--) {
2172
2184
  var target = actions[i][0],
2173
2185
  method = actions[i][1],
2174
- once = actions[i][2],
2175
- suspended = actions[i][3],
2186
+ flags = actions[i][2],
2176
2187
  actionIndex = indexOf(otherActions, target, method);
2177
2188
 
2178
2189
  if (actionIndex === -1) {
2179
- otherActions.push([target, method, once, suspended]);
2190
+ otherActions.push([target, method, flags]);
2180
2191
  }
2181
2192
  }
2182
2193
  }
@@ -2190,14 +2201,13 @@ function actionsDiff(obj, eventName, otherActions) {
2190
2201
  for (var i = actions.length - 1; i >= 0; i--) {
2191
2202
  var target = actions[i][0],
2192
2203
  method = actions[i][1],
2193
- once = actions[i][2],
2194
- suspended = actions[i][3],
2204
+ flags = actions[i][2],
2195
2205
  actionIndex = indexOf(otherActions, target, method);
2196
2206
 
2197
2207
  if (actionIndex !== -1) { continue; }
2198
2208
 
2199
- otherActions.push([target, method, once, suspended]);
2200
- diffActions.push([target, method, once, suspended]);
2209
+ otherActions.push([target, method, flags]);
2210
+ diffActions.push([target, method, flags]);
2201
2211
  }
2202
2212
 
2203
2213
  return diffActions;
@@ -2223,11 +2233,14 @@ function addListener(obj, eventName, target, method, once) {
2223
2233
  }
2224
2234
 
2225
2235
  var actions = actionsFor(obj, eventName),
2226
- actionIndex = indexOf(actions, target, method);
2236
+ actionIndex = indexOf(actions, target, method),
2237
+ flags = 0;
2238
+
2239
+ if (once) flags |= ONCE;
2227
2240
 
2228
2241
  if (actionIndex !== -1) { return; }
2229
2242
 
2230
- actions.push([target, method, once, undefined]);
2243
+ actions.push([target, method, flags]);
2231
2244
 
2232
2245
  if ('function' === typeof obj.didAddListener) {
2233
2246
  obj.didAddListener(eventName, target, method);
@@ -2254,7 +2267,7 @@ function removeListener(obj, eventName, target, method) {
2254
2267
  target = null;
2255
2268
  }
2256
2269
 
2257
- function _removeListener(target, method, once) {
2270
+ function _removeListener(target, method) {
2258
2271
  var actions = actionsFor(obj, eventName),
2259
2272
  actionIndex = indexOf(actions, target, method);
2260
2273
 
@@ -2311,12 +2324,12 @@ function suspendListener(obj, eventName, target, method, callback) {
2311
2324
 
2312
2325
  if (actionIndex !== -1) {
2313
2326
  action = actions[actionIndex].slice(); // copy it, otherwise we're modifying a shared object
2314
- action[3] = true; // mark the action as suspended
2327
+ action[2] |= SUSPENDED; // mark the action as suspended
2315
2328
  actions[actionIndex] = action; // replace the shared object with our copy
2316
2329
  }
2317
2330
 
2318
2331
  function tryable() { return callback.call(target); }
2319
- function finalizer() { if (action) { action[3] = undefined; } }
2332
+ function finalizer() { if (action) { action[2] &= ~SUSPENDED; } }
2320
2333
 
2321
2334
  return Ember.tryFinally(tryable, finalizer);
2322
2335
  }
@@ -2355,7 +2368,7 @@ function suspendListeners(obj, eventNames, target, method, callback) {
2355
2368
 
2356
2369
  if (actionIndex !== -1) {
2357
2370
  action = actions[actionIndex].slice();
2358
- action[3] = true;
2371
+ action[2] |= SUSPENDED;
2359
2372
  actions[actionIndex] = action;
2360
2373
  suspendedActions.push(action);
2361
2374
  }
@@ -2365,7 +2378,7 @@ function suspendListeners(obj, eventNames, target, method, callback) {
2365
2378
 
2366
2379
  function finalizer() {
2367
2380
  for (i = 0, l = suspendedActions.length; i < l; i++) {
2368
- suspendedActions[i][3] = undefined;
2381
+ suspendedActions[i][2] &= ~SUSPENDED;
2369
2382
  }
2370
2383
  }
2371
2384
 
@@ -2415,13 +2428,11 @@ function sendEvent(obj, eventName, params, actions) {
2415
2428
  if (!actions) { return; }
2416
2429
 
2417
2430
  for (var i = actions.length - 1; i >= 0; i--) { // looping in reverse for once listeners
2418
- if (!actions[i] || actions[i][3] === true) { continue; }
2419
-
2420
- var target = actions[i][0],
2421
- method = actions[i][1],
2422
- once = actions[i][2];
2423
-
2424
- if (once) { removeListener(obj, eventName, target, method); }
2431
+ var action = actions[i];
2432
+ if (!action) { continue; }
2433
+ var target = action[0], method = action[1], flags = action[2];
2434
+ if (flags & SUSPENDED) { continue; }
2435
+ if (flags & ONCE) { removeListener(obj, eventName, target, method); }
2425
2436
  if (!target) { target = obj; }
2426
2437
  if ('string' === typeof method) { method = target[method]; }
2427
2438
  if (params) {
@@ -2501,7 +2512,7 @@ var guidFor = Ember.guidFor,
2501
2512
  keyName: keyName,
2502
2513
  eventName: eventName,
2503
2514
  listeners: [
2504
- [target, method, onceFlag, suspendedFlag]
2515
+ [target, method, flags]
2505
2516
  ]
2506
2517
  },
2507
2518
  ...
@@ -2775,8 +2786,6 @@ var notifyObservers = function(obj, keyName) {
2775
2786
  var META_KEY = Ember.META_KEY,
2776
2787
  MANDATORY_SETTER = Ember.ENV.MANDATORY_SETTER,
2777
2788
  IS_GLOBAL = /^([A-Z$]|([0-9][A-Z$]))/,
2778
- propertyWillChange = Ember.propertyWillChange,
2779
- propertyDidChange = Ember.propertyDidChange,
2780
2789
  getPath = Ember._getPath;
2781
2790
 
2782
2791
  /**
@@ -2931,7 +2940,7 @@ var MANDATORY_SETTER = Ember.ENV.MANDATORY_SETTER;
2931
2940
  //
2932
2941
 
2933
2942
  /**
2934
- Objects of this type can implement an interface to responds requests to
2943
+ Objects of this type can implement an interface to respond to requests to
2935
2944
  get and set. The default implementation handles simple properties.
2936
2945
 
2937
2946
  You generally won't need to create or subclass this directly.
@@ -3236,7 +3245,6 @@ function isProto(pvalue) {
3236
3245
  // value for the key then the node won't actually watch it. For a root node
3237
3246
  // pass null for parent and key and object for value.
3238
3247
  var ChainNode = Ember._ChainNode = function(parent, key, value) {
3239
- var obj;
3240
3248
  this._parent = parent;
3241
3249
  this._key = key;
3242
3250
 
@@ -3685,7 +3693,7 @@ var get = Ember.get,
3685
3693
  This function returns a map of unique dependencies for a
3686
3694
  given object and key.
3687
3695
  */
3688
- function keysForDep(obj, depsMeta, depKey) {
3696
+ function keysForDep(depsMeta, depKey) {
3689
3697
  var keys = depsMeta[depKey];
3690
3698
  if (!keys) {
3691
3699
  // if there are no dependencies yet for a the given key
@@ -3699,8 +3707,8 @@ function keysForDep(obj, depsMeta, depKey) {
3699
3707
  return keys;
3700
3708
  }
3701
3709
 
3702
- function metaForDeps(obj, meta) {
3703
- return keysForDep(obj, meta, 'deps');
3710
+ function metaForDeps(meta) {
3711
+ return keysForDep(meta, 'deps');
3704
3712
  }
3705
3713
 
3706
3714
  function addDependentKeys(desc, obj, keyName, meta) {
@@ -3709,12 +3717,12 @@ function addDependentKeys(desc, obj, keyName, meta) {
3709
3717
  var depKeys = desc._dependentKeys, depsMeta, idx, len, depKey, keys;
3710
3718
  if (!depKeys) return;
3711
3719
 
3712
- depsMeta = metaForDeps(obj, meta);
3720
+ depsMeta = metaForDeps(meta);
3713
3721
 
3714
3722
  for(idx = 0, len = depKeys.length; idx < len; idx++) {
3715
3723
  depKey = depKeys[idx];
3716
3724
  // Lookup keys meta for depKey
3717
- keys = keysForDep(obj, depsMeta, depKey);
3725
+ keys = keysForDep(depsMeta, depKey);
3718
3726
  // Increment the number of times depKey depends on keyName.
3719
3727
  keys[keyName] = (keys[keyName] || 0) + 1;
3720
3728
  // Watch the depKey
@@ -3728,12 +3736,12 @@ function removeDependentKeys(desc, obj, keyName, meta) {
3728
3736
  var depKeys = desc._dependentKeys, depsMeta, idx, len, depKey, keys;
3729
3737
  if (!depKeys) return;
3730
3738
 
3731
- depsMeta = metaForDeps(obj, meta);
3739
+ depsMeta = metaForDeps(meta);
3732
3740
 
3733
3741
  for(idx = 0, len = depKeys.length; idx < len; idx++) {
3734
3742
  depKey = depKeys[idx];
3735
3743
  // Lookup keys meta for depKey
3736
- keys = keysForDep(obj, depsMeta, depKey);
3744
+ keys = keysForDep(depsMeta, depKey);
3737
3745
  // Increment the number of times depKey depends on keyName.
3738
3746
  keys[keyName] = (keys[keyName] || 0) - 1;
3739
3747
  // Watch the depKey
@@ -3764,25 +3772,29 @@ ComputedProperty.prototype = new Ember.Descriptor();
3764
3772
 
3765
3773
  var ComputedPropertyPrototype = ComputedProperty.prototype;
3766
3774
 
3767
- /**
3768
- Call on a computed property to set it into cacheable mode. When in this
3769
- mode the computed property will automatically cache the return value of
3770
- your function until one of the dependent keys changes.
3775
+ /*
3776
+ Call on a computed property to explicitly change it's cacheable mode.
3777
+
3778
+ Please use `.volatile` over this method.
3771
3779
 
3772
3780
  ```javascript
3773
3781
  MyApp.president = Ember.Object.create({
3774
3782
  fullName: function() {
3775
3783
  return this.get('firstName') + ' ' + this.get('lastName');
3776
3784
 
3777
- // After calculating the value of this function, Ember will
3778
- // return that value without re-executing this function until
3779
- // one of the dependent properties change.
3785
+ // By default, Ember will return the value of this property
3786
+ // without re-executing this function.
3780
3787
  }.property('firstName', 'lastName')
3788
+
3789
+ initials: function() {
3790
+ return this.get('firstName')[0] + this.get('lastName')[0];
3791
+
3792
+ // This function will be executed every time this property
3793
+ // is requested.
3794
+ }.property('firstName', 'lastName').cacheable(false)
3781
3795
  });
3782
3796
  ```
3783
3797
 
3784
- Properties are cacheable by default.
3785
-
3786
3798
  @method cacheable
3787
3799
  @param {Boolean} aFlag optional set to `false` to disable caching
3788
3800
  @return {Ember.ComputedProperty} this
@@ -4346,7 +4358,6 @@ Ember.computed.alias = function(dependentKey) {
4346
4358
  */
4347
4359
  Ember.computed.defaultTo = function(defaultPath) {
4348
4360
  return Ember.computed(function(key, newValue, cachedValue) {
4349
- var result;
4350
4361
  if (arguments.length === 1) {
4351
4362
  return cachedValue != null ? cachedValue : get(this, defaultPath);
4352
4363
  }
@@ -4506,8 +4517,6 @@ function invoke(target, method, args, ignore) {
4506
4517
  // RUNLOOP
4507
4518
  //
4508
4519
 
4509
- var timerMark; // used by timers...
4510
-
4511
4520
  /**
4512
4521
  Ember RunLoop (Private)
4513
4522
 
@@ -4638,8 +4647,6 @@ RunLoop.prototype = {
4638
4647
  }
4639
4648
  }
4640
4649
 
4641
- timerMark = null;
4642
-
4643
4650
  return this;
4644
4651
  }
4645
4652
 
@@ -4755,7 +4762,7 @@ Ember.run.queues = ['sync', 'actions', 'destroy'];
4755
4762
 
4756
4763
  At the end of a RunLoop, any methods scheduled in this way will be invoked.
4757
4764
  Methods will be invoked in an order matching the named queues defined in
4758
- the `run.queues` property.
4765
+ the `Ember.run.queues` property.
4759
4766
 
4760
4767
  ```javascript
4761
4768
  Ember.run.schedule('sync', this, function(){
@@ -4864,27 +4871,44 @@ Ember.run.sync = function() {
4864
4871
 
4865
4872
  var timers = {}; // active timers...
4866
4873
 
4874
+ function sortByExpires(timerA, timerB) {
4875
+ var a = timerA.expires,
4876
+ b = timerB.expires;
4877
+
4878
+ if (a > b) { return 1; }
4879
+ if (a < b) { return -1; }
4880
+ return 0;
4881
+ }
4882
+
4867
4883
  var scheduledLater, scheduledLaterExpires;
4868
4884
  function invokeLaterTimers() {
4869
4885
  scheduledLater = null;
4870
4886
  run(function() {
4871
4887
  var now = (+ new Date()), earliest = -1;
4888
+ var timersToBeInvoked = [];
4872
4889
  for (var key in timers) {
4873
4890
  if (!timers.hasOwnProperty(key)) { continue; }
4874
4891
  var timer = timers[key];
4875
4892
  if (timer && timer.expires) {
4876
4893
  if (now >= timer.expires) {
4877
4894
  delete timers[key];
4878
- invoke(timer.target, timer.method, timer.args, 2);
4895
+ timersToBeInvoked.push(timer);
4879
4896
  } else {
4880
4897
  if (earliest < 0 || (timer.expires < earliest)) { earliest = timer.expires; }
4881
4898
  }
4882
4899
  }
4883
4900
  }
4884
4901
 
4902
+ forEach.call(timersToBeInvoked.sort(sortByExpires), function(timer) {
4903
+ invoke(timer.target, timer.method, timer.args, 2);
4904
+ });
4905
+
4885
4906
  // schedule next timeout to fire when the earliest timer expires
4886
4907
  if (earliest > 0) {
4887
- scheduledLater = setTimeout(invokeLaterTimers, earliest - now);
4908
+ // To allow overwrite `setTimeout` as stub from test code.
4909
+ // The assignment to `window.setTimeout` doesn't equal to `setTimeout` in older IE.
4910
+ // So `window` is required.
4911
+ scheduledLater = window.setTimeout(invokeLaterTimers, earliest - now);
4888
4912
  scheduledLaterExpires = earliest;
4889
4913
  }
4890
4914
  });
@@ -4986,8 +5010,25 @@ function scheduleOnce(queue, target, method, args) {
4986
5010
  }
4987
5011
 
4988
5012
  /**
4989
- Schedules an item to run one time during the current RunLoop. Calling
4990
- this method with the same target/method combination will have no effect.
5013
+ Schedule a function to run one time during the current RunLoop. This is equivalent
5014
+ to calling `scheduleOnce` with the "actions" queue.
5015
+
5016
+ @method once
5017
+ @param {Object} [target] The target of the method to invoke.
5018
+ @param {Function|String} method The method to invoke.
5019
+ If you pass a string it will be resolved on the
5020
+ target at the time the method is invoked.
5021
+ @param {Object} [args*] Optional arguments to pass to the timeout.
5022
+ @return {Object} timer
5023
+ */
5024
+ Ember.run.once = function(target, method) {
5025
+ return scheduleOnce('actions', target, method, slice.call(arguments, 2));
5026
+ };
5027
+
5028
+ /**
5029
+ Schedules a function to run one time in a given queue of the current RunLoop.
5030
+ Calling this method with the same queue/target/method combination will have
5031
+ no effect (past the initial call).
4991
5032
 
4992
5033
  Note that although you can pass optional arguments these will not be
4993
5034
  considered when looking for duplicates. New arguments will replace previous
@@ -4995,41 +5036,40 @@ function scheduleOnce(queue, target, method, args) {
4995
5036
 
4996
5037
  ```javascript
4997
5038
  Ember.run(function(){
4998
- var doFoo = function() { foo(); }
4999
- Ember.run.once(myContext, doFoo);
5000
- Ember.run.once(myContext, doFoo);
5001
- // doFoo will only be executed once at the end of the RunLoop
5039
+ var sayHi = function() { console.log('hi'); }
5040
+ Ember.run.scheduleOnce('afterRender', myContext, sayHi);
5041
+ Ember.run.scheduleOnce('afterRender', myContext, sayHi);
5042
+ // doFoo will only be executed once, in the afterRender queue of the RunLoop
5002
5043
  });
5003
5044
  ```
5004
5045
 
5005
- Also note that passing an anonymous function to `Ember.run.once` will
5046
+ Also note that passing an anonymous function to `Ember.run.scheduleOnce` will
5006
5047
  not prevent additional calls with an identical anonymous function from
5007
5048
  scheduling the items multiple times, e.g.:
5008
5049
 
5009
5050
  ```javascript
5010
5051
  function scheduleIt() {
5011
- Ember.run.once(myContext, function() { console.log("Closure"); });
5052
+ Ember.run.scheduleOnce('actions', myContext, function() { console.log("Closure"); });
5012
5053
  }
5013
5054
  scheduleIt();
5014
5055
  scheduleIt();
5015
- // "Closure" will print twice, even though we're using `Ember.run.once`,
5056
+ // "Closure" will print twice, even though we're using `Ember.run.scheduleOnce`,
5016
5057
  // because the function we pass to it is anonymous and won't match the
5017
5058
  // previously scheduled operation.
5018
5059
  ```
5019
5060
 
5020
- @method once
5021
- @param {Object} [target] target of method to invoke
5061
+ Available queues, and their order, can be found at `Ember.run.queues`
5062
+
5063
+ @method scheduleOnce
5064
+ @param {String} [queue] The name of the queue to schedule against. Default queues are 'sync' and 'actions'.
5065
+ @param {Object} [target] The target of the method to invoke.
5022
5066
  @param {Function|String} method The method to invoke.
5023
5067
  If you pass a string it will be resolved on the
5024
5068
  target at the time the method is invoked.
5025
5069
  @param {Object} [args*] Optional arguments to pass to the timeout.
5026
5070
  @return {Object} timer
5027
5071
  */
5028
- Ember.run.once = function(target, method) {
5029
- return scheduleOnce('actions', target, method, slice.call(arguments, 2));
5030
- };
5031
-
5032
- Ember.run.scheduleOnce = function(queue, target, method, args) {
5072
+ Ember.run.scheduleOnce = function(queue, target, method) {
5033
5073
  return scheduleOnce(queue, target, method, slice.call(arguments, 3));
5034
5074
  };
5035
5075
 
@@ -5465,7 +5505,7 @@ mixinProperties(Binding, {
5465
5505
  Properties ending in a `Binding` suffix will be converted to `Ember.Binding`
5466
5506
  instances. The value of this property should be a string representing a path
5467
5507
  to another object or a custom binding instanced created using Binding helpers
5468
- (see "Customizing Your Bindings"):
5508
+ (see "One Way Bindings"):
5469
5509
 
5470
5510
  ```
5471
5511
  valueBinding: "MyApp.someController.title"
@@ -6204,7 +6244,7 @@ Ember.alias = function(methodName) {
6204
6244
  return new Alias(methodName);
6205
6245
  };
6206
6246
 
6207
- Ember.deprecateFunc("Ember.alias is deprecated. Please use Ember.aliasMethod or Ember.computed.alias instead.", Ember.alias);
6247
+ Ember.alias = Ember.deprecateFunc("Ember.alias is deprecated. Please use Ember.aliasMethod or Ember.computed.alias instead.", Ember.alias);
6208
6248
 
6209
6249
  /**
6210
6250
  Makes a method available via an additional name.
@@ -6292,14 +6332,57 @@ Ember Metal
6292
6332
  })();
6293
6333
 
6294
6334
  (function() {
6295
- define("rsvp",
6296
- [],
6297
- function() {
6335
+ define("rsvp/all",
6336
+ ["rsvp/defer","exports"],
6337
+ function(__dependency1__, __exports__) {
6338
+ "use strict";
6339
+ var defer = __dependency1__.defer;
6340
+
6341
+ function all(promises) {
6342
+ var results = [], deferred = defer(), remaining = promises.length;
6343
+
6344
+ if (remaining === 0) {
6345
+ deferred.resolve([]);
6346
+ }
6347
+
6348
+ var resolver = function(index) {
6349
+ return function(value) {
6350
+ resolveAll(index, value);
6351
+ };
6352
+ };
6353
+
6354
+ var resolveAll = function(index, value) {
6355
+ results[index] = value;
6356
+ if (--remaining === 0) {
6357
+ deferred.resolve(results);
6358
+ }
6359
+ };
6360
+
6361
+ var rejectAll = function(error) {
6362
+ deferred.reject(error);
6363
+ };
6364
+
6365
+ for (var i = 0; i < promises.length; i++) {
6366
+ if (promises[i] && typeof promises[i].then === 'function') {
6367
+ promises[i].then(resolver(i), rejectAll);
6368
+ } else {
6369
+ resolveAll(i, promises[i]);
6370
+ }
6371
+ }
6372
+ return deferred.promise;
6373
+ }
6374
+
6375
+ __exports__.all = all;
6376
+ });
6377
+
6378
+ define("rsvp/async",
6379
+ ["exports"],
6380
+ function(__exports__) {
6298
6381
  "use strict";
6299
6382
  var browserGlobal = (typeof window !== 'undefined') ? window : {};
6300
6383
 
6301
- var MutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver;
6302
- var RSVP, async;
6384
+ var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver;
6385
+ var async;
6303
6386
 
6304
6387
  if (typeof process !== 'undefined' &&
6305
6388
  {}.toString.call(process) === '[object process]') {
@@ -6308,10 +6391,10 @@ define("rsvp",
6308
6391
  callback.call(binding);
6309
6392
  });
6310
6393
  };
6311
- } else if (MutationObserver) {
6394
+ } else if (BrowserMutationObserver) {
6312
6395
  var queue = [];
6313
6396
 
6314
- var observer = new MutationObserver(function() {
6397
+ var observer = new BrowserMutationObserver(function() {
6315
6398
  var toProcess = queue.slice();
6316
6399
  queue = [];
6317
6400
 
@@ -6342,6 +6425,47 @@ define("rsvp",
6342
6425
  };
6343
6426
  }
6344
6427
 
6428
+
6429
+ __exports__.async = async;
6430
+ });
6431
+
6432
+ define("rsvp/config",
6433
+ ["rsvp/async","exports"],
6434
+ function(__dependency1__, __exports__) {
6435
+ "use strict";
6436
+ var async = __dependency1__.async;
6437
+
6438
+ var config = {};
6439
+ config.async = async;
6440
+
6441
+ __exports__.config = config;
6442
+ });
6443
+
6444
+ define("rsvp/defer",
6445
+ ["rsvp/promise","exports"],
6446
+ function(__dependency1__, __exports__) {
6447
+ "use strict";
6448
+ var Promise = __dependency1__.Promise;
6449
+
6450
+ function defer() {
6451
+ var deferred = {};
6452
+
6453
+ var promise = new Promise(function(resolve, reject) {
6454
+ deferred.resolve = resolve;
6455
+ deferred.reject = reject;
6456
+ });
6457
+
6458
+ deferred.promise = promise;
6459
+ return deferred;
6460
+ }
6461
+
6462
+ __exports__.defer = defer;
6463
+ });
6464
+
6465
+ define("rsvp/events",
6466
+ ["exports"],
6467
+ function(__exports__) {
6468
+ "use strict";
6345
6469
  var Event = function(type, options) {
6346
6470
  this.type = type;
6347
6471
 
@@ -6436,7 +6560,148 @@ define("rsvp",
6436
6560
  }
6437
6561
  };
6438
6562
 
6439
- var Promise = function() {
6563
+
6564
+ __exports__.EventTarget = EventTarget;
6565
+ });
6566
+
6567
+ define("rsvp/hash",
6568
+ ["rsvp/defer","exports"],
6569
+ function(__dependency1__, __exports__) {
6570
+ "use strict";
6571
+ var defer = __dependency1__.defer;
6572
+
6573
+ function size(object) {
6574
+ var size = 0;
6575
+
6576
+ for (var prop in object) {
6577
+ size++;
6578
+ }
6579
+
6580
+ return size;
6581
+ }
6582
+
6583
+ function hash(promises) {
6584
+ var results = {}, deferred = defer(), remaining = size(promises);
6585
+
6586
+ if (remaining === 0) {
6587
+ deferred.resolve({});
6588
+ }
6589
+
6590
+ var resolver = function(prop) {
6591
+ return function(value) {
6592
+ resolveAll(prop, value);
6593
+ };
6594
+ };
6595
+
6596
+ var resolveAll = function(prop, value) {
6597
+ results[prop] = value;
6598
+ if (--remaining === 0) {
6599
+ deferred.resolve(results);
6600
+ }
6601
+ };
6602
+
6603
+ var rejectAll = function(error) {
6604
+ deferred.reject(error);
6605
+ };
6606
+
6607
+ for (var prop in promises) {
6608
+ if (promises[prop] && typeof promises[prop].then === 'function') {
6609
+ promises[prop].then(resolver(prop), rejectAll);
6610
+ } else {
6611
+ resolveAll(prop, promises[prop]);
6612
+ }
6613
+ }
6614
+
6615
+ return deferred.promise;
6616
+ }
6617
+
6618
+ __exports__.hash = hash;
6619
+ });
6620
+
6621
+ define("rsvp/node",
6622
+ ["rsvp/promise","rsvp/all","exports"],
6623
+ function(__dependency1__, __dependency2__, __exports__) {
6624
+ "use strict";
6625
+ var Promise = __dependency1__.Promise;
6626
+ var all = __dependency2__.all;
6627
+
6628
+ function makeNodeCallbackFor(resolve, reject) {
6629
+ return function (error, value) {
6630
+ if (error) {
6631
+ reject(error);
6632
+ } else if (arguments.length > 2) {
6633
+ resolve(Array.prototype.slice.call(arguments, 1));
6634
+ } else {
6635
+ resolve(value);
6636
+ }
6637
+ };
6638
+ }
6639
+
6640
+ function denodeify(nodeFunc) {
6641
+ return function() {
6642
+ var nodeArgs = Array.prototype.slice.call(arguments), resolve, reject;
6643
+
6644
+ var promise = new Promise(function(nodeResolve, nodeReject) {
6645
+ resolve = nodeResolve;
6646
+ reject = nodeReject;
6647
+ });
6648
+
6649
+ all(nodeArgs).then(function(nodeArgs) {
6650
+ nodeArgs.push(makeNodeCallbackFor(resolve, reject));
6651
+
6652
+ try {
6653
+ nodeFunc.apply(this, nodeArgs);
6654
+ } catch(e) {
6655
+ reject(e);
6656
+ }
6657
+ });
6658
+
6659
+ return promise;
6660
+ };
6661
+ }
6662
+
6663
+ __exports__.denodeify = denodeify;
6664
+ });
6665
+
6666
+ define("rsvp/promise",
6667
+ ["rsvp/config","rsvp/events","exports"],
6668
+ function(__dependency1__, __dependency2__, __exports__) {
6669
+ "use strict";
6670
+ var config = __dependency1__.config;
6671
+ var EventTarget = __dependency2__.EventTarget;
6672
+
6673
+ function objectOrFunction(x) {
6674
+ return isFunction(x) || (typeof x === "object" && x !== null);
6675
+ }
6676
+
6677
+ function isFunction(x){
6678
+ return typeof x === "function";
6679
+ }
6680
+
6681
+ var Promise = function(resolver) {
6682
+ var promise = this,
6683
+ resolved = false;
6684
+
6685
+ if (typeof resolver !== 'function') {
6686
+ throw new TypeError('You must pass a resolver function as the sole argument to the promise constructor');
6687
+ }
6688
+
6689
+ if (!(promise instanceof Promise)) {
6690
+ return new Promise(resolver);
6691
+ }
6692
+
6693
+ var resolvePromise = function(value) {
6694
+ if (resolved) { return; }
6695
+ resolved = true;
6696
+ resolve(promise, value);
6697
+ };
6698
+
6699
+ var rejectPromise = function(value) {
6700
+ if (resolved) { return; }
6701
+ resolved = true;
6702
+ reject(promise, value);
6703
+ };
6704
+
6440
6705
  this.on('promise:resolved', function(event) {
6441
6706
  this.trigger('success', { detail: event.detail });
6442
6707
  }, this);
@@ -6444,12 +6709,12 @@ define("rsvp",
6444
6709
  this.on('promise:failed', function(event) {
6445
6710
  this.trigger('error', { detail: event.detail });
6446
6711
  }, this);
6447
- };
6448
6712
 
6449
- var noop = function() {};
6713
+ resolver(resolvePromise, rejectPromise);
6714
+ };
6450
6715
 
6451
6716
  var invokeCallback = function(type, promise, callback, event) {
6452
- var hasCallback = typeof callback === 'function',
6717
+ var hasCallback = isFunction(callback),
6453
6718
  value, error, succeeded, failed;
6454
6719
 
6455
6720
  if (hasCallback) {
@@ -6465,34 +6730,34 @@ define("rsvp",
6465
6730
  succeeded = true;
6466
6731
  }
6467
6732
 
6468
- if (value && typeof value.then === 'function') {
6469
- value.then(function(value) {
6470
- promise.resolve(value);
6471
- }, function(error) {
6472
- promise.reject(error);
6473
- });
6733
+ if (handleThenable(promise, value)) {
6734
+ return;
6474
6735
  } else if (hasCallback && succeeded) {
6475
- promise.resolve(value);
6736
+ resolve(promise, value);
6476
6737
  } else if (failed) {
6477
- promise.reject(error);
6478
- } else {
6479
- promise[type](value);
6738
+ reject(promise, error);
6739
+ } else if (type === 'resolve') {
6740
+ resolve(promise, value);
6741
+ } else if (type === 'reject') {
6742
+ reject(promise, value);
6480
6743
  }
6481
6744
  };
6482
6745
 
6483
6746
  Promise.prototype = {
6747
+ constructor: Promise,
6748
+
6484
6749
  then: function(done, fail) {
6485
- var thenPromise = new Promise();
6750
+ var thenPromise = new Promise(function() {});
6486
6751
 
6487
- if (this.isResolved) {
6488
- RSVP.async(function() {
6489
- invokeCallback('resolve', thenPromise, done, { detail: this.resolvedValue });
6752
+ if (this.isFulfilled) {
6753
+ config.async(function() {
6754
+ invokeCallback('resolve', thenPromise, done, { detail: this.fulfillmentValue });
6490
6755
  }, this);
6491
6756
  }
6492
6757
 
6493
6758
  if (this.isRejected) {
6494
- RSVP.async(function() {
6495
- invokeCallback('reject', thenPromise, fail, { detail: this.rejectedValue });
6759
+ config.async(function() {
6760
+ invokeCallback('reject', thenPromise, fail, { detail: this.rejectedReason });
6496
6761
  }, this);
6497
6762
  }
6498
6763
 
@@ -6505,75 +6770,138 @@ define("rsvp",
6505
6770
  });
6506
6771
 
6507
6772
  return thenPromise;
6508
- },
6773
+ }
6774
+ };
6509
6775
 
6510
- resolve: function(value) {
6511
- resolve(this, value);
6776
+ EventTarget.mixin(Promise.prototype);
6512
6777
 
6513
- this.resolve = noop;
6514
- this.reject = noop;
6515
- },
6778
+ function resolve(promise, value) {
6779
+ if (promise === value) {
6780
+ fulfill(promise, value);
6781
+ } else if (!handleThenable(promise, value)) {
6782
+ fulfill(promise, value);
6783
+ }
6784
+ }
6516
6785
 
6517
- reject: function(value) {
6518
- reject(this, value);
6786
+ function handleThenable(promise, value) {
6787
+ var then = null;
6788
+
6789
+ if (objectOrFunction(value)) {
6790
+ try {
6791
+ then = value.then;
6792
+ } catch(e) {
6793
+ reject(promise, e);
6794
+ return true;
6795
+ }
6519
6796
 
6520
- this.resolve = noop;
6521
- this.reject = noop;
6797
+ if (isFunction(then)) {
6798
+ try {
6799
+ then.call(value, function(val) {
6800
+ if (value !== val) {
6801
+ resolve(promise, val);
6802
+ } else {
6803
+ fulfill(promise, val);
6804
+ }
6805
+ }, function(val) {
6806
+ reject(promise, val);
6807
+ });
6808
+ } catch (e) {
6809
+ reject(promise, e);
6810
+ }
6811
+ return true;
6812
+ }
6522
6813
  }
6523
- };
6524
6814
 
6525
- function resolve(promise, value) {
6526
- RSVP.async(function() {
6815
+ return false;
6816
+ }
6817
+
6818
+ function fulfill(promise, value) {
6819
+ config.async(function() {
6527
6820
  promise.trigger('promise:resolved', { detail: value });
6528
- promise.isResolved = true;
6529
- promise.resolvedValue = value;
6821
+ promise.isFulfilled = true;
6822
+ promise.fulfillmentValue = value;
6530
6823
  });
6531
6824
  }
6532
6825
 
6533
6826
  function reject(promise, value) {
6534
- RSVP.async(function() {
6827
+ config.async(function() {
6535
6828
  promise.trigger('promise:failed', { detail: value });
6536
6829
  promise.isRejected = true;
6537
- promise.rejectedValue = value;
6830
+ promise.rejectedReason = value;
6538
6831
  });
6539
6832
  }
6540
6833
 
6541
- function all(promises) {
6542
- var i, results = [];
6543
- var allPromise = new Promise();
6544
- var remaining = promises.length;
6545
6834
 
6546
- if (remaining === 0) {
6547
- allPromise.resolve([]);
6548
- }
6835
+ __exports__.Promise = Promise;
6836
+ });
6549
6837
 
6550
- var resolver = function(index) {
6551
- return function(value) {
6552
- resolve(index, value);
6553
- };
6554
- };
6838
+ define("rsvp/resolve",
6839
+ ["rsvp/promise","exports"],
6840
+ function(__dependency1__, __exports__) {
6841
+ "use strict";
6842
+ var Promise = __dependency1__.Promise;
6555
6843
 
6556
- var resolve = function(index, value) {
6557
- results[index] = value;
6558
- if (--remaining === 0) {
6559
- allPromise.resolve(results);
6560
- }
6561
- };
6562
6844
 
6563
- var reject = function(error) {
6564
- allPromise.reject(error);
6565
- };
6845
+ function objectOrFunction(x) {
6846
+ return typeof x === "function" || (typeof x === "object" && x !== null);
6847
+ }
6566
6848
 
6567
- for (i = 0; i < remaining; i++) {
6568
- promises[i].then(resolver(i), reject);
6569
- }
6570
- return allPromise;
6849
+ function resolve(thenable){
6850
+ var promise = new Promise(function(resolve, reject){
6851
+ var then;
6852
+
6853
+ try {
6854
+ if ( objectOrFunction(thenable) ) {
6855
+ then = thenable.then;
6856
+
6857
+ if (typeof then === "function") {
6858
+ then.call(thenable, resolve, reject);
6859
+ } else {
6860
+ resolve(thenable);
6861
+ }
6862
+
6863
+ } else {
6864
+ resolve(thenable);
6865
+ }
6866
+
6867
+ } catch(error) {
6868
+ reject(error);
6869
+ }
6870
+ });
6871
+
6872
+ return promise;
6571
6873
  }
6572
6874
 
6573
- EventTarget.mixin(Promise.prototype);
6574
6875
 
6575
- RSVP = { async: async, Promise: Promise, Event: Event, EventTarget: EventTarget, all: all, raiseOnUncaughtExceptions: true };
6576
- return RSVP;
6876
+ __exports__.resolve = resolve;
6877
+ });
6878
+
6879
+ define("rsvp",
6880
+ ["rsvp/events","rsvp/promise","rsvp/node","rsvp/all","rsvp/hash","rsvp/defer","rsvp/config","rsvp/resolve","exports"],
6881
+ function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __exports__) {
6882
+ "use strict";
6883
+ var EventTarget = __dependency1__.EventTarget;
6884
+ var Promise = __dependency2__.Promise;
6885
+ var denodeify = __dependency3__.denodeify;
6886
+ var all = __dependency4__.all;
6887
+ var hash = __dependency5__.hash;
6888
+ var defer = __dependency6__.defer;
6889
+ var config = __dependency7__.config;
6890
+ var resolve = __dependency8__.resolve;
6891
+
6892
+ function configure(name, value) {
6893
+ config[name] = value;
6894
+ }
6895
+
6896
+
6897
+ __exports__.Promise = Promise;
6898
+ __exports__.EventTarget = EventTarget;
6899
+ __exports__.all = all;
6900
+ __exports__.hash = hash;
6901
+ __exports__.defer = defer;
6902
+ __exports__.denodeify = denodeify;
6903
+ __exports__.configure = configure;
6904
+ __exports__.resolve = resolve;
6577
6905
  });
6578
6906
 
6579
6907
  })();
@@ -6819,7 +7147,7 @@ define("container",
6819
7147
  var factory = factoryFor(container, fullName);
6820
7148
 
6821
7149
  var splitName = fullName.split(":"),
6822
- type = splitName[0], name = splitName[1],
7150
+ type = splitName[0],
6823
7151
  value;
6824
7152
 
6825
7153
  if (option(container, fullName, 'instantiate') === false) {
@@ -7228,7 +7556,8 @@ Ember.String = {
7228
7556
  ```
7229
7557
 
7230
7558
  @method fmt
7231
- @param {Object...} [args]
7559
+ @param {String} str The string to format
7560
+ @param {Array} formats An array of parameters to interpolate into string.
7232
7561
  @return {String} formatted string
7233
7562
  */
7234
7563
  fmt: function(str, formats) {
@@ -8558,9 +8887,7 @@ Ember.Enumerable = Ember.Mixin.create({
8558
8887
  // HELPERS
8559
8888
  //
8560
8889
 
8561
- var get = Ember.get, set = Ember.set, map = Ember.EnumerableUtils.map, cacheFor = Ember.cacheFor;
8562
-
8563
- function none(obj) { return obj===null || obj===undefined; }
8890
+ var get = Ember.get, set = Ember.set, isNone = Ember.isNone, map = Ember.EnumerableUtils.map, cacheFor = Ember.cacheFor;
8564
8891
 
8565
8892
  // ..........................................................
8566
8893
  // ARRAY
@@ -8710,8 +9037,8 @@ Ember.Array = Ember.Mixin.create(Ember.Enumerable, /** @scope Ember.Array.protot
8710
9037
  slice: function(beginIndex, endIndex) {
8711
9038
  var ret = Ember.A([]);
8712
9039
  var length = get(this, 'length') ;
8713
- if (none(beginIndex)) beginIndex = 0 ;
8714
- if (none(endIndex) || (endIndex > length)) endIndex = length ;
9040
+ if (isNone(beginIndex)) beginIndex = 0 ;
9041
+ if (isNone(endIndex) || (endIndex > length)) endIndex = length ;
8715
9042
 
8716
9043
  if (beginIndex < 0) beginIndex = length + beginIndex;
8717
9044
  if (endIndex < 0) endIndex = length + endIndex;
@@ -8871,7 +9198,7 @@ Ember.Array = Ember.Mixin.create(Ember.Enumerable, /** @scope Ember.Array.protot
8871
9198
  @param {Number} startIdx The starting index in the array that will change.
8872
9199
  @param {Number} removeAmt The number of items that will be removed. If you
8873
9200
  pass `null` assumes 0
8874
- @param {Number} addAmt The number of items that will be added If you
9201
+ @param {Number} addAmt The number of items that will be added. If you
8875
9202
  pass `null` assumes 0.
8876
9203
  @return {Ember.Array} receiver
8877
9204
  */
@@ -8905,6 +9232,20 @@ Ember.Array = Ember.Mixin.create(Ember.Enumerable, /** @scope Ember.Array.protot
8905
9232
  return this;
8906
9233
  },
8907
9234
 
9235
+ /**
9236
+ If you are implementing an object that supports `Ember.Array`, call this
9237
+ method just after the array content changes to notify any observers and
9238
+ invalidate any related properties. Pass the starting index of the change
9239
+ as well as a delta of the amounts to change.
9240
+
9241
+ @method arrayContentDidChange
9242
+ @param {Number} startIdx The starting index in the array that did change.
9243
+ @param {Number} removeAmt The number of items that were removed. If you
9244
+ pass `null` assumes 0
9245
+ @param {Number} addAmt The number of items that were added. If you
9246
+ pass `null` assumes 0.
9247
+ @return {Ember.Array} receiver
9248
+ */
8908
9249
  arrayContentDidChange: function(startIdx, removeAmt, addAmt) {
8909
9250
 
8910
9251
  // if no args are passed assume everything changes
@@ -9205,7 +9546,7 @@ var forEach = Ember.EnumerableUtils.forEach;
9205
9546
 
9206
9547
  To add an object to an enumerable, use the `addObject()` method. This
9207
9548
  method will only add the object to the enumerable if the object is not
9208
- already present and the object if of a type supported by the enumerable.
9549
+ already present and is of a type supported by the enumerable.
9209
9550
 
9210
9551
  ```javascript
9211
9552
  set.addObject(contact);
@@ -9213,8 +9554,8 @@ var forEach = Ember.EnumerableUtils.forEach;
9213
9554
 
9214
9555
  ## Removing Objects
9215
9556
 
9216
- To remove an object form an enumerable, use the `removeObject()` method. This
9217
- will only remove the object if it is already in the enumerable, otherwise
9557
+ To remove an object from an enumerable, use the `removeObject()` method. This
9558
+ will only remove the object if it is present in the enumerable, otherwise
9218
9559
  this method has no effect.
9219
9560
 
9220
9561
  ```javascript
@@ -9241,7 +9582,7 @@ Ember.MutableEnumerable = Ember.Mixin.create(Ember.Enumerable, {
9241
9582
  already present in the collection. If the object is present, this method
9242
9583
  has no effect.
9243
9584
 
9244
- If the passed object is of a type not supported by the receiver
9585
+ If the passed object is of a type not supported by the receiver,
9245
9586
  then this method should raise an exception.
9246
9587
 
9247
9588
  @method addObject
@@ -9268,10 +9609,10 @@ Ember.MutableEnumerable = Ember.Mixin.create(Ember.Enumerable, {
9268
9609
  __Required.__ You must implement this method to apply this mixin.
9269
9610
 
9270
9611
  Attempts to remove the passed object from the receiver collection if the
9271
- object is in present in the collection. If the object is not present,
9612
+ object is present in the collection. If the object is not present,
9272
9613
  this method has no effect.
9273
9614
 
9274
- If the passed object is of a type not supported by the receiver
9615
+ If the passed object is of a type not supported by the receiver,
9275
9616
  then this method should raise an exception.
9276
9617
 
9277
9618
  @method removeObject
@@ -9282,7 +9623,7 @@ Ember.MutableEnumerable = Ember.Mixin.create(Ember.Enumerable, {
9282
9623
 
9283
9624
 
9284
9625
  /**
9285
- Removes each objects in the passed enumerable from the receiver.
9626
+ Removes each object in the passed enumerable from the receiver.
9286
9627
 
9287
9628
  @method removeObjects
9288
9629
  @param {Ember.Enumerable} objects the objects to remove
@@ -10063,7 +10404,7 @@ Ember.Observable = Ember.Mixin.create(/** @scope Ember.Observable.prototype */ {
10063
10404
  @return {Object} The new property value
10064
10405
  */
10065
10406
  incrementProperty: function(keyName, increment) {
10066
- if (!increment) { increment = 1; }
10407
+ if (Ember.isNone(increment)) { increment = 1; }
10067
10408
  set(this, keyName, (get(this, keyName) || 0)+increment);
10068
10409
  return get(this, keyName);
10069
10410
  },
@@ -10082,7 +10423,7 @@ Ember.Observable = Ember.Mixin.create(/** @scope Ember.Observable.prototype */ {
10082
10423
  @return {Object} The new property value
10083
10424
  */
10084
10425
  decrementProperty: function(keyName, increment) {
10085
- if (!increment) { increment = 1; }
10426
+ if (Ember.isNone(increment)) { increment = 1; }
10086
10427
  set(this, keyName, (get(this, keyName) || 0)-increment);
10087
10428
  return get(this, keyName);
10088
10429
  },
@@ -10138,6 +10479,15 @@ Ember.Observable = Ember.Mixin.create(/** @scope Ember.Observable.prototype */ {
10138
10479
  var get = Ember.get, set = Ember.set;
10139
10480
 
10140
10481
  /**
10482
+ `Ember.TargetActionSupport` is a mixin that can be included in a class
10483
+ to add a `triggerAction` method with semantics similar to the Handlebars
10484
+ `{{action}}` helper. In normal Ember usage, the `{{action}}` helper is
10485
+ usually the best choice. This mixin is most often useful when you are
10486
+ doing more complex event handling in View objects.
10487
+
10488
+ See also `Ember.ViewTargetActionSupport`, which has
10489
+ view-aware defaults for target and actionContext.
10490
+
10141
10491
  @class TargetActionSupport
10142
10492
  @namespace Ember
10143
10493
  @extends Ember.Mixin
@@ -10145,6 +10495,7 @@ var get = Ember.get, set = Ember.set;
10145
10495
  Ember.TargetActionSupport = Ember.Mixin.create({
10146
10496
  target: null,
10147
10497
  action: null,
10498
+ actionContext: null,
10148
10499
 
10149
10500
  targetObject: Ember.computed(function() {
10150
10501
  var target = get(this, 'target');
@@ -10158,21 +10509,86 @@ Ember.TargetActionSupport = Ember.Mixin.create({
10158
10509
  }
10159
10510
  }).property('target'),
10160
10511
 
10161
- triggerAction: function() {
10162
- var action = get(this, 'action'),
10163
- target = get(this, 'targetObject');
10512
+ actionContextObject: Ember.computed(function() {
10513
+ var actionContext = get(this, 'actionContext');
10514
+
10515
+ if (Ember.typeOf(actionContext) === "string") {
10516
+ var value = get(this, actionContext);
10517
+ if (value === undefined) { value = get(Ember.lookup, actionContext); }
10518
+ return value;
10519
+ } else {
10520
+ return actionContext;
10521
+ }
10522
+ }).property('actionContext'),
10523
+
10524
+ /**
10525
+ Send an "action" with an "actionContext" to a "target". The action, actionContext
10526
+ and target will be retrieved from properties of the object. For example:
10527
+
10528
+ ```javascript
10529
+ App.SaveButtonView = Ember.View.extend(Ember.TargetActionSupport, {
10530
+ target: Ember.computed.alias('controller'),
10531
+ action: 'save',
10532
+ actionContext: Ember.computed.alias('context'),
10533
+ click: function(){
10534
+ this.triggerAction(); // Sends the `save` action, along with the current context
10535
+ // to the current controller
10536
+ }
10537
+ });
10538
+ ```
10539
+
10540
+ The `target`, `action`, and `actionContext` can be provided as properties of
10541
+ an optional object argument to `triggerAction` as well.
10542
+
10543
+ ```javascript
10544
+ App.SaveButtonView = Ember.View.extend(Ember.TargetActionSupport, {
10545
+ click: function(){
10546
+ this.triggerAction({
10547
+ action: 'save',
10548
+ target: this.get('controller'),
10549
+ actionContext: this.get('context'),
10550
+ }); // Sends the `save` action, along with the current context
10551
+ // to the current controller
10552
+ }
10553
+ });
10554
+ ```
10555
+
10556
+ The `actionContext` defaults to the object you mixing `TargetActionSupport` into.
10557
+ But `target` and `action` must be specified either as properties or with the argument
10558
+ to `triggerAction`, or a combination:
10559
+
10560
+ ```javascript
10561
+ App.SaveButtonView = Ember.View.extend(Ember.TargetActionSupport, {
10562
+ target: Ember.computed.alias('controller'),
10563
+ click: function(){
10564
+ this.triggerAction({
10565
+ action: 'save'
10566
+ }); // Sends the `save` action, along with a reference to `this`,
10567
+ // to the current controller
10568
+ }
10569
+ });
10570
+ ```
10571
+
10572
+ @method triggerAction
10573
+ @param opts {Hash} (optional, with the optional keys action, target and/or actionContext)
10574
+ @return {Boolean} true if the action was sent successfully and did not return false
10575
+ */
10576
+ triggerAction: function(opts) {
10577
+ opts = opts || {};
10578
+ var action = opts['action'] || get(this, 'action'),
10579
+ target = opts['target'] || get(this, 'targetObject'),
10580
+ actionContext = opts['actionContext'] || get(this, 'actionContextObject') || this;
10164
10581
 
10165
10582
  if (target && action) {
10166
10583
  var ret;
10167
10584
 
10168
- if (typeof target.send === 'function') {
10169
- ret = target.send(action, this);
10585
+ if (target.send) {
10586
+ ret = target.send.apply(target, [action, actionContext]);
10170
10587
  } else {
10171
- if (typeof action === 'string') {
10172
- action = target[action];
10173
- }
10174
- ret = action.call(target, this);
10588
+ Ember.assert("The action '" + action + "' did not exist on " + target, typeof target[action] === 'function');
10589
+ ret = target[action].apply(target, [actionContext]);
10175
10590
  }
10591
+
10176
10592
  if (ret !== false) ret = true;
10177
10593
 
10178
10594
  return ret;
@@ -10344,9 +10760,9 @@ Ember.Evented = Ember.Mixin.create({
10344
10760
  (function() {
10345
10761
  var RSVP = requireModule("rsvp");
10346
10762
 
10347
- RSVP.async = function(callback, binding) {
10763
+ RSVP.configure('async', function(callback, binding) {
10348
10764
  Ember.run.schedule('actions', binding, callback);
10349
- };
10765
+ });
10350
10766
 
10351
10767
  /**
10352
10768
  @module ember
@@ -10368,9 +10784,22 @@ Ember.DeferredMixin = Ember.Mixin.create({
10368
10784
  @param {Function} doneCallback a callback function to be called when done
10369
10785
  @param {Function} failCallback a callback function to be called when failed
10370
10786
  */
10371
- then: function(doneCallback, failCallback) {
10372
- var promise = get(this, 'promise');
10373
- return promise.then.apply(promise, arguments);
10787
+ then: function(resolve, reject) {
10788
+ var deferred, promise, entity;
10789
+
10790
+ entity = this;
10791
+ deferred = get(this, '_deferred');
10792
+ promise = deferred.promise;
10793
+
10794
+ return promise.then(function(fulfillment) {
10795
+ if (fulfillment === promise) {
10796
+ return resolve(entity);
10797
+ } else {
10798
+ return resolve(fulfillment);
10799
+ }
10800
+ }, function(reason) {
10801
+ return reject(reason);
10802
+ });
10374
10803
  },
10375
10804
 
10376
10805
  /**
@@ -10379,7 +10808,16 @@ Ember.DeferredMixin = Ember.Mixin.create({
10379
10808
  @method resolve
10380
10809
  */
10381
10810
  resolve: function(value) {
10382
- get(this, 'promise').resolve(value);
10811
+ var deferred, promise;
10812
+
10813
+ deferred = get(this, '_deferred');
10814
+ promise = deferred.promise;
10815
+
10816
+ if (value === this){
10817
+ deferred.resolve(promise);
10818
+ } else {
10819
+ deferred.resolve(value);
10820
+ }
10383
10821
  },
10384
10822
 
10385
10823
  /**
@@ -10388,11 +10826,11 @@ Ember.DeferredMixin = Ember.Mixin.create({
10388
10826
  @method reject
10389
10827
  */
10390
10828
  reject: function(value) {
10391
- get(this, 'promise').reject(value);
10829
+ get(this, '_deferred').reject(value);
10392
10830
  },
10393
10831
 
10394
- promise: Ember.computed(function() {
10395
- return new RSVP.Promise();
10832
+ _deferred: Ember.computed(function() {
10833
+ return new RSVP.defer();
10396
10834
  })
10397
10835
  });
10398
10836
 
@@ -11081,7 +11519,7 @@ function findNamespaces() {
11081
11519
 
11082
11520
  for (var prop in lookup) {
11083
11521
  // These don't raise exceptions but can cause warnings
11084
- if (prop === "parent" || prop === "top" || prop === "frameElement") { continue; }
11522
+ if (prop === "parent" || prop === "top" || prop === "frameElement" || prop === "webkitStorageInfo") { continue; }
11085
11523
 
11086
11524
  // get(window.globalStorage, 'isNamespace') would try to read the storage for domain isNamespace and cause exception in Firefox.
11087
11525
  // globalStorage is a storage obsoleted by the WhatWG storage specification. See https://developer.mozilla.org/en/DOM/Storage#globalStorage
@@ -11993,9 +12431,8 @@ if (ignore.length>0) {
11993
12431
  @namespace Ember
11994
12432
  @extends Ember.Mixin
11995
12433
  @uses Ember.MutableArray
11996
- @uses Ember.MutableEnumerable
12434
+ @uses Ember.Observable
11997
12435
  @uses Ember.Copyable
11998
- @uses Ember.Freezable
11999
12436
  */
12000
12437
  Ember.NativeArray = NativeArray;
12001
12438
 
@@ -12042,7 +12479,7 @@ if (Ember.EXTEND_PROTOTYPES === true || Ember.EXTEND_PROTOTYPES.Array) {
12042
12479
  @submodule ember-runtime
12043
12480
  */
12044
12481
 
12045
- var get = Ember.get, set = Ember.set, guidFor = Ember.guidFor, none = Ember.isNone, fmt = Ember.String.fmt;
12482
+ var get = Ember.get, set = Ember.set, guidFor = Ember.guidFor, isNone = Ember.isNone, fmt = Ember.String.fmt;
12046
12483
 
12047
12484
  /**
12048
12485
  An unordered collection of objects.
@@ -12400,7 +12837,7 @@ Ember.Set = Ember.CoreObject.extend(Ember.MutableEnumerable, Ember.Copyable, Emb
12400
12837
  // implements Ember.MutableEnumerable
12401
12838
  addObject: function(obj) {
12402
12839
  if (get(this, 'isFrozen')) throw new Error(Ember.FROZEN_ERROR);
12403
- if (none(obj)) return this; // nothing to do
12840
+ if (isNone(obj)) return this; // nothing to do
12404
12841
 
12405
12842
  var guid = guidFor(obj),
12406
12843
  idx = this[guid],
@@ -12428,7 +12865,7 @@ Ember.Set = Ember.CoreObject.extend(Ember.MutableEnumerable, Ember.Copyable, Emb
12428
12865
  // implements Ember.MutableEnumerable
12429
12866
  removeObject: function(obj) {
12430
12867
  if (get(this, 'isFrozen')) throw new Error(Ember.FROZEN_ERROR);
12431
- if (none(obj)) return this; // nothing to do
12868
+ if (isNone(obj)) return this; // nothing to do
12432
12869
 
12433
12870
  var guid = guidFor(obj),
12434
12871
  idx = this[guid],
@@ -12503,7 +12940,7 @@ Deferred.reopenClass({
12503
12940
  promise: function(callback, binding) {
12504
12941
  var deferred = Deferred.create();
12505
12942
  callback.call(binding, deferred);
12506
- return get(deferred, 'promise');
12943
+ return deferred;
12507
12944
  }
12508
12945
  });
12509
12946
 
@@ -12514,6 +12951,8 @@ Ember.Deferred = Deferred;
12514
12951
 
12515
12952
 
12516
12953
  (function() {
12954
+ var forEach = Ember.ArrayPolyfills.forEach;
12955
+
12517
12956
  /**
12518
12957
  @module ember
12519
12958
  @submodule ember-runtime
@@ -12546,12 +12985,10 @@ Ember.onLoad = function(name, callback) {
12546
12985
  @param object {Object} object to pass to callbacks
12547
12986
  */
12548
12987
  Ember.runLoadHooks = function(name, object) {
12549
- var hooks;
12550
-
12551
12988
  loaded[name] = object;
12552
12989
 
12553
- if (hooks = loadHooks[name]) {
12554
- loadHooks[name].forEach(function(callback) {
12990
+ if (loadHooks[name]) {
12991
+ forEach.call(loadHooks[name], function(callback) {
12555
12992
  callback(object);
12556
12993
  });
12557
12994
  }
@@ -13006,9 +13443,9 @@ Ember.ArrayController = Ember.ArrayProxy.extend(Ember.ControllerMixin,
13006
13443
  });
13007
13444
  ```
13008
13445
 
13009
- @method
13010
- @type String
13011
- @default null
13446
+ @method lookupItemController
13447
+ @param {Object} object
13448
+ @return {String}
13012
13449
  */
13013
13450
  lookupItemController: function(object) {
13014
13451
  return get(this, 'itemController');
@@ -13086,10 +13523,11 @@ Ember.ArrayController = Ember.ArrayProxy.extend(Ember.ControllerMixin,
13086
13523
 
13087
13524
  _resetSubControllers: function() {
13088
13525
  var subControllers = get(this, '_subControllers');
13089
-
13090
- forEach(subControllers, function(subController) {
13091
- if (subController) { subController.destroy(); }
13092
- });
13526
+ if (subControllers) {
13527
+ forEach(subControllers, function(subController) {
13528
+ if (subController) { subController.destroy(); }
13529
+ });
13530
+ }
13093
13531
 
13094
13532
  this.set('_subControllers', Ember.A());
13095
13533
  }
@@ -13245,8 +13683,26 @@ Ember.State = Ember.Object.extend(Ember.Evented,
13245
13683
  }
13246
13684
  }
13247
13685
 
13248
- set(this, 'pathsCache', {});
13249
- set(this, 'pathsCacheNoContext', {});
13686
+ // pathsCaches is a nested hash of the form:
13687
+ // pathsCaches[stateManagerTypeGuid][path] == transitions_hash
13688
+ set(this, 'pathsCaches', {});
13689
+ },
13690
+
13691
+ setPathsCache: function(stateManager, path, transitions) {
13692
+ var stateManagerTypeGuid = Ember.guidFor(stateManager.constructor),
13693
+ pathsCaches = get(this, 'pathsCaches'),
13694
+ pathsCacheForManager = pathsCaches[stateManagerTypeGuid] || {};
13695
+
13696
+ pathsCacheForManager[path] = transitions;
13697
+ pathsCaches[stateManagerTypeGuid] = pathsCacheForManager;
13698
+ },
13699
+
13700
+ getPathsCache: function(stateManager, path) {
13701
+ var stateManagerTypeGuid = Ember.guidFor(stateManager.constructor),
13702
+ pathsCaches = get(this, 'pathsCaches'),
13703
+ pathsCacheForManager = pathsCaches[stateManagerTypeGuid] || {};
13704
+
13705
+ return pathsCacheForManager[path];
13250
13706
  },
13251
13707
 
13252
13708
  setupChild: function(states, name, value) {
@@ -14234,7 +14690,7 @@ Ember.StateManager = Ember.State.extend({
14234
14690
  },
14235
14691
 
14236
14692
  contextFreeTransition: function(currentState, path) {
14237
- var cache = currentState.pathsCache[path];
14693
+ var cache = currentState.getPathsCache(this, path);
14238
14694
  if (cache) { return cache; }
14239
14695
 
14240
14696
  var enterStates = this.getStatesInPath(currentState, path),
@@ -14320,12 +14776,14 @@ Ember.StateManager = Ember.State.extend({
14320
14776
 
14321
14777
  // Cache the enterStates, exitStates, and resolveState for the
14322
14778
  // current state and the `path`.
14323
- var transitions = currentState.pathsCache[path] = {
14779
+ var transitions = {
14324
14780
  exitStates: exitStates,
14325
14781
  enterStates: enterStates,
14326
14782
  resolveState: resolveState
14327
14783
  };
14328
14784
 
14785
+ currentState.setPathsCache(this, path, transitions);
14786
+
14329
14787
  return transitions;
14330
14788
  },
14331
14789