ember-source 1.0.0.rc5.1 → 1.0.0.rc6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


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

data/VERSION CHANGED
@@ -1 +1 @@
1
- v1.0.0-rc.5.1
1
+ 1.0.0-rc.6
@@ -1,5 +1,5 @@
1
- // Version: v1.0.0-rc.5-2-g9dc4ad8
2
- // Last commit: 9dc4ad8 (2013-07-25 20:19:21 -0400)
1
+ // Version: v1.0.0-rc.6-1-g42f0c68
2
+ // Last commit: 42f0c68 (2013-06-23 15:43:35 -0400)
3
3
 
4
4
 
5
5
  (function() {
@@ -49,7 +49,12 @@ if (!('MANDATORY_SETTER' in Ember.ENV)) {
49
49
  falsy, an exception will be thrown.
50
50
  */
51
51
  Ember.assert = function(desc, test) {
52
- if (!test) throw new Error("assertion failed: "+desc);
52
+ Ember.Logger.assert(test, desc);
53
+
54
+ if (Ember.testing && !test) {
55
+ // when testing, ensure test failures when assertions fail
56
+ throw new Error("Assertion Failed: " + desc);
57
+ }
53
58
  };
54
59
 
55
60
 
@@ -95,12 +100,12 @@ Ember.debug = function(message) {
95
100
  will be displayed.
96
101
  */
97
102
  Ember.deprecate = function(message, test) {
98
- if (Ember && Ember.TESTING_DEPRECATION) { return; }
103
+ if (Ember.TESTING_DEPRECATION) { return; }
99
104
 
100
105
  if (arguments.length === 1) { test = false; }
101
106
  if (test) { return; }
102
107
 
103
- if (Ember && Ember.ENV.RAISE_ON_DEPRECATION) { throw new Error(message); }
108
+ if (Ember.ENV.RAISE_ON_DEPRECATION) { throw new Error(message); }
104
109
 
105
110
  var error;
106
111
 
@@ -151,8 +156,8 @@ Ember.deprecateFunc = function(message, func) {
151
156
 
152
157
  })();
153
158
 
154
- // Version: v1.0.0-rc.5-2-g9dc4ad8
155
- // Last commit: 9dc4ad8 (2013-07-25 20:19:21 -0400)
159
+ // Version: v1.0.0-rc.6-1-g42f0c68
160
+ // Last commit: 42f0c68 (2013-06-23 15:43:35 -0400)
156
161
 
157
162
 
158
163
  (function() {
@@ -219,7 +224,7 @@ var define, requireModule;
219
224
 
220
225
  @class Ember
221
226
  @static
222
- @version 1.0.0-rc.5
227
+ @version 1.0.0-rc.6
223
228
  */
224
229
 
225
230
  if ('undefined' === typeof Ember) {
@@ -246,10 +251,10 @@ Ember.toString = function() { return "Ember"; };
246
251
  /**
247
252
  @property VERSION
248
253
  @type String
249
- @default '1.0.0-rc.5'
254
+ @default '1.0.0-rc.6'
250
255
  @final
251
256
  */
252
- Ember.VERSION = '1.0.0-rc.5';
257
+ Ember.VERSION = '1.0.0-rc.6';
253
258
 
254
259
  /**
255
260
  Standard environmental variables. You can define these in a global `ENV`
@@ -364,6 +369,19 @@ function consoleMethod(name) {
364
369
  }
365
370
  }
366
371
 
372
+ function assertPolyfill(test, message) {
373
+ if (!test) {
374
+ try {
375
+ // attempt to preserve the stack
376
+ throw new Error("assertion failed: " + message);
377
+ } catch(error) {
378
+ setTimeout(function(){
379
+ throw error;
380
+ }, 0);
381
+ }
382
+ }
383
+ }
384
+
367
385
  /**
368
386
  Inside Ember-Metal, simply uses the methods from `imports.console`.
369
387
  Override this to provide more robust logging functionality.
@@ -376,7 +394,8 @@ Ember.Logger = {
376
394
  warn: consoleMethod('warn') || Ember.K,
377
395
  error: consoleMethod('error') || Ember.K,
378
396
  info: consoleMethod('info') || Ember.K,
379
- debug: consoleMethod('debug') || consoleMethod('info') || Ember.K
397
+ debug: consoleMethod('debug') || consoleMethod('info') || Ember.K,
398
+ assert: consoleMethod('assert') || assertPolyfill
380
399
  };
381
400
 
382
401
 
@@ -1644,6 +1663,7 @@ get = function get(obj, keyName) {
1644
1663
  obj = null;
1645
1664
  }
1646
1665
 
1666
+ Ember.assert("Cannot call get with "+ keyName +" key.", !!keyName);
1647
1667
  Ember.assert("Cannot call get with '"+ keyName +"' on an undefined object.", obj !== undefined);
1648
1668
 
1649
1669
  if (obj === null || keyName.indexOf('.') !== -1) {
@@ -1676,12 +1696,21 @@ if (Ember.config.overrideAccessors) {
1676
1696
  get = Ember.get;
1677
1697
  }
1678
1698
 
1679
- function firstKey(path) {
1680
- return path.match(FIRST_KEY)[0];
1681
- }
1699
+ /**
1700
+ @private
1701
+
1702
+ Normalizes a target/path pair to reflect that actual target/path that should
1703
+ be observed, etc. This takes into account passing in global property
1704
+ paths (i.e. a path beginning with a captial letter not defined on the
1705
+ target) and * separators.
1682
1706
 
1683
- // assumes path is already normalized
1684
- function normalizeTuple(target, path) {
1707
+ @method normalizeTuple
1708
+ @for Ember
1709
+ @param {Object} target The current target. May be `null`.
1710
+ @param {String} path A path on the target or a global property path.
1711
+ @return {Array} a temporary array with the normalized target/path pair.
1712
+ */
1713
+ var normalizeTuple = Ember.normalizeTuple = function(target, path) {
1685
1714
  var hasThis = HAS_THIS.test(path),
1686
1715
  isGlobal = !hasThis && IS_GLOBAL_PATH.test(path),
1687
1716
  key;
@@ -1690,7 +1719,7 @@ function normalizeTuple(target, path) {
1690
1719
  if (hasThis) path = path.slice(5);
1691
1720
 
1692
1721
  if (target === Ember.lookup) {
1693
- key = firstKey(path);
1722
+ key = path.match(FIRST_KEY)[0];
1694
1723
  target = get(target, key);
1695
1724
  path = path.slice(key.length+1);
1696
1725
  }
@@ -1699,7 +1728,7 @@ function normalizeTuple(target, path) {
1699
1728
  if (!path || path.length===0) throw new Error('Invalid Path');
1700
1729
 
1701
1730
  return [ target, path ];
1702
- }
1731
+ };
1703
1732
 
1704
1733
  var getPath = Ember._getPath = function(root, path) {
1705
1734
  var hasThis, parts, tuple, idx, len;
@@ -1728,24 +1757,6 @@ var getPath = Ember._getPath = function(root, path) {
1728
1757
  return root;
1729
1758
  };
1730
1759
 
1731
- /**
1732
- @private
1733
-
1734
- Normalizes a target/path pair to reflect that actual target/path that should
1735
- be observed, etc. This takes into account passing in global property
1736
- paths (i.e. a path beginning with a captial letter not defined on the
1737
- target) and * separators.
1738
-
1739
- @method normalizeTuple
1740
- @for Ember
1741
- @param {Object} target The current target. May be `null`.
1742
- @param {String} path A path on the target or a global property path.
1743
- @return {Array} a temporary array with the normalized target/path pair.
1744
- */
1745
- Ember.normalizeTuple = function(target, path) {
1746
- return normalizeTuple(target, path);
1747
- };
1748
-
1749
1760
  Ember.getWithDefault = function(root, key, defaultValue) {
1750
1761
  var value = get(root, key);
1751
1762
 
@@ -2465,6 +2476,8 @@ var set = function set(obj, keyName, value, tolerant) {
2465
2476
  obj = null;
2466
2477
  }
2467
2478
 
2479
+ Ember.assert("Cannot call set with "+ keyName +" key.", !!keyName);
2480
+
2468
2481
  if (!obj || keyName.indexOf('.') !== -1) {
2469
2482
  return setPath(obj, keyName, value, tolerant);
2470
2483
  }
@@ -3116,9 +3129,9 @@ var changeProperties = Ember.changeProperties,
3116
3129
  observers will be buffered.
3117
3130
 
3118
3131
  @method setProperties
3119
- @param target
3120
- @param {Hash} properties
3121
- @return target
3132
+ @param self
3133
+ @param {Object} hash
3134
+ @return self
3122
3135
  */
3123
3136
  Ember.setProperties = function(self, hash) {
3124
3137
  changeProperties(function(){
@@ -4758,7 +4771,7 @@ define("backburner",
4758
4771
  },
4759
4772
 
4760
4773
  cancel: function(timer) {
4761
- if (typeof timer === 'object' && timer.queue && timer.method) { // we're cancelling a deferOnce
4774
+ if (timer && typeof timer === 'object' && timer.queue && timer.method) { // we're cancelling a deferOnce
4762
4775
  return timer.queue.cancel(timer);
4763
4776
  } else if (typeof timer === 'function') { // we're cancelling a setTimeout
4764
4777
  for (var i = 0, l = timers.length; i < l; i += 2) {
@@ -4767,6 +4780,8 @@ define("backburner",
4767
4780
  return true;
4768
4781
  }
4769
4782
  }
4783
+ } else {
4784
+ return; // timer was null or not a timer
4770
4785
  }
4771
4786
  }
4772
4787
  };
@@ -4859,7 +4874,7 @@ define("backburner/deferred_action_queues",
4859
4874
  while (queueNameIndex < numberOfQueues) {
4860
4875
  queueName = queueNames[queueNameIndex];
4861
4876
  queue = queues[queueName];
4862
- queueItems = queue._queue.slice();
4877
+ queueItems = queue._queueBeingFlushed = queue._queue.slice();
4863
4878
  queue._queue = [];
4864
4879
 
4865
4880
  var options = queue.options,
@@ -4877,15 +4892,19 @@ define("backburner/deferred_action_queues",
4877
4892
 
4878
4893
  if (typeof method === 'string') { method = target[method]; }
4879
4894
 
4880
- // TODO: error handling
4881
- if (args && args.length > 0) {
4882
- method.apply(target, args);
4883
- } else {
4884
- method.call(target);
4895
+ // method could have been nullified / canceled during flush
4896
+ if (method) {
4897
+ // TODO: error handling
4898
+ if (args && args.length > 0) {
4899
+ method.apply(target, args);
4900
+ } else {
4901
+ method.call(target);
4902
+ }
4885
4903
  }
4886
4904
 
4887
4905
  queueIndex += 4;
4888
4906
  }
4907
+ queue._queueBeingFlushed = null;
4889
4908
  if (numberOfQueueItems && after) { after(); }
4890
4909
 
4891
4910
  if ((priorQueueNameIndex = indexOfPriorQueueWithActions(this, queueNameIndex)) !== -1) {
@@ -4910,6 +4929,7 @@ define("backburner/deferred_action_queues",
4910
4929
  return -1;
4911
4930
  }
4912
4931
 
4932
+
4913
4933
  __exports__.DeferredActionQueues = DeferredActionQueues;
4914
4934
  });
4915
4935
 
@@ -4999,12 +5019,30 @@ define("backburner/queue",
4999
5019
  return true;
5000
5020
  }
5001
5021
  }
5022
+
5023
+ // if not found in current queue
5024
+ // could be in the queue that is being flushed
5025
+ queue = this._queueBeingFlushed;
5026
+ if (!queue) {
5027
+ return;
5028
+ }
5029
+ for (i = 0, l = queue.length; i < l; i += 4) {
5030
+ currentTarget = queue[i];
5031
+ currentMethod = queue[i+1];
5032
+
5033
+ if (currentTarget === actionToCancel.target && currentMethod === actionToCancel.method) {
5034
+ // don't mess with array during flush
5035
+ // just nullify the method
5036
+ queue[i+1] = null;
5037
+ return true;
5038
+ }
5039
+ }
5002
5040
  }
5003
5041
  };
5004
5042
 
5043
+
5005
5044
  __exports__.Queue = Queue;
5006
5045
  });
5007
-
5008
5046
  })();
5009
5047
 
5010
5048
 
@@ -5112,7 +5150,7 @@ Ember.run = function(target, method) {
5112
5150
  May be a function or a string. If you pass a string
5113
5151
  then it will be looked up on the passed target.
5114
5152
  @param {Object} [args*] Any additional arguments you wish to pass to the method.
5115
- @return {Object} return value from invoking the passed function. Please note,
5153
+ @return {Object} return value from invoking the passed function. Please note,
5116
5154
  when called within an existing loop, no return value is possible.
5117
5155
  */
5118
5156
  Ember.run.join = function(target, method) {
@@ -5248,7 +5286,9 @@ Ember.run.cancelTimers = function () {
5248
5286
  @return {void}
5249
5287
  */
5250
5288
  Ember.run.sync = function() {
5251
- backburner.currentInstance.queues.sync.flush();
5289
+ if (backburner.currentInstance) {
5290
+ backburner.currentInstance.queues.sync.flush();
5291
+ }
5252
5292
  };
5253
5293
 
5254
5294
  /**
@@ -5441,6 +5481,38 @@ Ember.run.cancel = function(timer) {
5441
5481
  return backburner.cancel(timer);
5442
5482
  };
5443
5483
 
5484
+ /**
5485
+ Execute the passed method in a specified amount of time, reset timer
5486
+ upon additional calls.
5487
+
5488
+ ```javascript
5489
+ var myFunc = function() { console.log(this.name + ' ran.'); };
5490
+ var myContext = {name: 'debounce'};
5491
+
5492
+ Ember.run.debounce(myContext, myFunc, 150);
5493
+
5494
+ // less than 150ms passes
5495
+
5496
+ Ember.run.debounce(myContext, myFunc, 150);
5497
+
5498
+ // 150ms passes
5499
+ // myFunc is invoked with context myContext
5500
+ // console logs 'debounce ran.' one time.
5501
+ ```
5502
+
5503
+ @method debounce
5504
+ @param {Object} [target] target of method to invoke
5505
+ @param {Function|String} method The method to invoke.
5506
+ May be a function or a string. If you pass a string
5507
+ then it will be looked up on the passed target.
5508
+ @param {Object} [args*] Optional arguments to pass to the timeout.
5509
+ @param {Number} wait Number of milliseconds to wait.
5510
+ @return {void}
5511
+ */
5512
+ Ember.run.debounce = function() {
5513
+ return backburner.debounce.apply(backburner, arguments);
5514
+ };
5515
+
5444
5516
  // Make sure it's not an autorun during testing
5445
5517
  function checkAutoRun() {
5446
5518
  if (!Ember.run.currentRunLoop) {
@@ -7230,6 +7302,8 @@ define("rsvp",
7230
7302
  __exports__.reject = reject;
7231
7303
  });
7232
7304
 
7305
+
7306
+
7233
7307
  })();
7234
7308
 
7235
7309
  (function() {
@@ -7354,6 +7428,10 @@ define("container",
7354
7428
  return value;
7355
7429
  },
7356
7430
 
7431
+ lookupFactory: function(fullName) {
7432
+ return factoryFor(this, fullName);
7433
+ },
7434
+
7357
7435
  has: function(fullName) {
7358
7436
  if (this.cache.has(fullName)) {
7359
7437
  return true;
@@ -8074,8 +8152,8 @@ Ember.String = {
8074
8152
  ```
8075
8153
 
8076
8154
  @method capitalize
8077
- @param {String} str
8078
- @return {String}
8155
+ @param {String} str The string to capitalize.
8156
+ @return {String} The capitalized string.
8079
8157
  */
8080
8158
  capitalize: function(str) {
8081
8159
  return str.charAt(0).toUpperCase() + str.substr(1);
@@ -9448,15 +9526,15 @@ Ember.Array = Ember.Mixin.create(Ember.Enumerable, /** @scope Ember.Array.protot
9448
9526
  Adds an array observer to the receiving array. The array observer object
9449
9527
  normally must implement two methods:
9450
9528
 
9451
- * `arrayWillChange(start, removeCount, addCount)` - This method will be
9529
+ * `arrayWillChange(observedObj, start, removeCount, addCount)` - This method will be
9452
9530
  called just before the array is modified.
9453
- * `arrayDidChange(start, removeCount, addCount)` - This method will be
9531
+ * `arrayDidChange(observedObj, start, removeCount, addCount)` - This method will be
9454
9532
  called just after the array is modified.
9455
9533
 
9456
- Both callbacks will be passed the starting index of the change as well a
9457
- a count of the items to be removed and added. You can use these callbacks
9458
- to optionally inspect the array during the change, clear caches, or do
9459
- any other bookkeeping necessary.
9534
+ Both callbacks will be passed the observed object, starting index of the
9535
+ change as well a a count of the items to be removed and added. You can use
9536
+ these callbacks to optionally inspect the array during the change, clear
9537
+ caches, or do any other bookkeeping necessary.
9460
9538
 
9461
9539
  In addition to passing a target, you can also include an options hash
9462
9540
  which you can use to override the method names that will be invoked on the
@@ -13464,17 +13542,40 @@ Ember.SortableMixin = Ember.Mixin.create(Ember.MutableEnumerable, {
13464
13542
  @property {Boolean} sortAscending
13465
13543
  */
13466
13544
  sortAscending: true,
13545
+
13546
+ /**
13547
+ The function used to compare two values. You can override this if you
13548
+ want to do custom comparisons.Functions must be of the type expected by
13549
+ Array#sort, i.e.
13550
+ return 0 if the two parameters are equal,
13551
+ return a negative value if the first parameter is smaller than the second or
13552
+ return a positive value otherwise:
13553
+
13554
+ ```javascript
13555
+ function(x,y){ // These are assumed to be integers
13556
+ if(x === y)
13557
+ return 0;
13558
+ return x < y ? -1 : 1;
13559
+ }
13560
+ ```
13467
13561
 
13562
+ @property sortFunction
13563
+ @type {Function}
13564
+ @default Ember.compare
13565
+ */
13566
+ sortFunction: Ember.compare,
13567
+
13468
13568
  orderBy: function(item1, item2) {
13469
13569
  var result = 0,
13470
13570
  sortProperties = get(this, 'sortProperties'),
13471
- sortAscending = get(this, 'sortAscending');
13571
+ sortAscending = get(this, 'sortAscending'),
13572
+ sortFunction = get(this, 'sortFunction');
13472
13573
 
13473
13574
  Ember.assert("you need to define `sortProperties`", !!sortProperties);
13474
13575
 
13475
13576
  forEach(sortProperties, function(propertyName) {
13476
13577
  if (result === 0) {
13477
- result = Ember.compare(get(item1, propertyName), get(item2, propertyName));
13578
+ result = sortFunction(get(item1, propertyName), get(item2, propertyName));
13478
13579
  if ((result !== 0) && !sortAscending) {
13479
13580
  result = (-1) * result;
13480
13581
  }
@@ -13921,8 +14022,6 @@ var get = Ember.get, set = Ember.set;
13921
14022
  */
13922
14023
  Ember.State = Ember.Object.extend(Ember.Evented,
13923
14024
  /** @scope Ember.State.prototype */{
13924
- isState: true,
13925
-
13926
14025
  /**
13927
14026
  A reference to the parent state.
13928
14027
 
@@ -14032,20 +14131,24 @@ Ember.State = Ember.Object.extend(Ember.Evented,
14032
14131
 
14033
14132
  setupChild: function(states, name, value) {
14034
14133
  if (!value) { return false; }
14134
+ var instance;
14035
14135
 
14036
- if (value.isState) {
14136
+ if (value instanceof Ember.State) {
14037
14137
  set(value, 'name', name);
14138
+ instance = value;
14139
+ instance.container = this.container;
14038
14140
  } else if (Ember.State.detect(value)) {
14039
- value = value.create({
14040
- name: name
14141
+ instance = value.create({
14142
+ name: name,
14143
+ container: this.container
14041
14144
  });
14042
14145
  }
14043
14146
 
14044
- if (value.isState) {
14045
- set(value, 'parentState', this);
14046
- get(this, 'childStates').pushObject(value);
14047
- states[name] = value;
14048
- return value;
14147
+ if (instance instanceof Ember.State) {
14148
+ set(instance, 'parentState', this);
14149
+ get(this, 'childStates').pushObject(instance);
14150
+ states[name] = instance;
14151
+ return instance;
14049
14152
  }
14050
14153
  },
14051
14154