ember-source 2.1.0.beta.3 → 2.1.0

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.

@@ -5,7 +5,7 @@
5
5
  * Portions Copyright 2008-2011 Apple Inc. All rights reserved.
6
6
  * @license Licensed under MIT license
7
7
  * See https://raw.github.com/emberjs/ember.js/master/LICENSE
8
- * @version 2.1.0-beta.3
8
+ * @version 2.1.0
9
9
  */
10
10
 
11
11
  (function() {
@@ -129,13 +129,23 @@ enifed('backburner', ['exports', './backburner/utils', './backburner/platform',
129
129
  this.instanceStack = [];
130
130
  this._debouncees = [];
131
131
  this._throttlers = [];
132
- this._timers = [];
133
132
  this._eventCallbacks = {
134
133
  end: [],
135
134
  begin: []
136
135
  };
136
+
137
+ this._timerTimeoutId = undefined;
138
+ this._timers = [];
139
+
140
+ var _this = this;
141
+ this._boundRunExpiredTimers = function () {
142
+ _this._runExpiredTimers();
143
+ };
137
144
  }
138
145
 
146
+ // ms of delay before we conclude a timeout was lost
147
+ var TIMEOUT_STALLED_THRESHOLD = 1000;
148
+
139
149
  Backburner.prototype = {
140
150
  begin: function () {
141
151
  var options = this.options;
@@ -291,39 +301,60 @@ enifed('backburner', ['exports', './backburner/utils', './backburner/platform',
291
301
  }
292
302
  },
293
303
 
304
+ /*
305
+ Join the passed method with an existing queue and execute immediately,
306
+ if there isn't one use `Backburner#run`.
307
+ The join method is like the run method except that it will schedule into
308
+ an existing queue if one already exists. In either case, the join method will
309
+ immediately execute the passed in function and return its result.
310
+ @method join
311
+ @param {Object} target
312
+ @param {Function} method The method to be executed
313
+ @param {any} args The method arguments
314
+ @return method result
315
+ */
294
316
  join: function () /* target, method, args */{
295
- if (this.currentInstance) {
296
- var length = arguments.length;
297
- var method, target;
317
+ if (!this.currentInstance) {
318
+ return this.run.apply(this, arguments);
319
+ }
298
320
 
299
- if (length === 1) {
300
- method = arguments[0];
301
- target = null;
302
- } else {
303
- target = arguments[0];
304
- method = arguments[1];
305
- }
321
+ var length = arguments.length;
322
+ var method, target;
306
323
 
307
- if (_backburnerUtils.isString(method)) {
308
- method = target[method];
309
- }
324
+ if (length === 1) {
325
+ method = arguments[0];
326
+ target = null;
327
+ } else {
328
+ target = arguments[0];
329
+ method = arguments[1];
330
+ }
310
331
 
311
- if (length === 1) {
312
- return method();
313
- } else if (length === 2) {
314
- return method.call(target);
315
- } else {
316
- var args = new Array(length - 2);
317
- for (var i = 0, l = length - 2; i < l; i++) {
318
- args[i] = arguments[i + 2];
319
- }
320
- return method.apply(target, args);
321
- }
332
+ if (_backburnerUtils.isString(method)) {
333
+ method = target[method];
334
+ }
335
+
336
+ if (length === 1) {
337
+ return method();
338
+ } else if (length === 2) {
339
+ return method.call(target);
322
340
  } else {
323
- return this.run.apply(this, arguments);
341
+ var args = new Array(length - 2);
342
+ for (var i = 0, l = length - 2; i < l; i++) {
343
+ args[i] = arguments[i + 2];
344
+ }
345
+ return method.apply(target, args);
324
346
  }
325
347
  },
326
348
 
349
+ /*
350
+ Defer the passed function to run inside the specified queue.
351
+ @method defer
352
+ @param {String} queueName
353
+ @param {Object} target
354
+ @param {Function|String} method The method or method name to be executed
355
+ @param {any} args The method arguments
356
+ @return method result
357
+ */
327
358
  defer: function (queueName /* , target, method, args */) {
328
359
  var length = arguments.length;
329
360
  var method, target, args;
@@ -466,12 +497,27 @@ enifed('backburner', ['exports', './backburner/utils', './backburner/platform',
466
497
  }
467
498
  }
468
499
 
500
+ return this._setTimeout(fn, executeAt);
501
+ },
502
+
503
+ _setTimeout: function (fn, executeAt) {
504
+ if (this._timers.length === 0) {
505
+ this._timers.push(executeAt, fn);
506
+ this._installTimerTimeout();
507
+ return fn;
508
+ }
509
+
510
+ this._reinstallStalledTimerTimeout();
511
+
469
512
  // find position to insert
470
513
  var i = _backburnerBinarySearch.default(executeAt, this._timers);
471
514
 
472
515
  this._timers.splice(i, 0, executeAt, fn);
473
516
 
474
- updateLaterTimer(this, executeAt, wait);
517
+ // we should be the new earliest timer if i == 0
518
+ if (i === 0) {
519
+ this._reinstallTimerTimeout();
520
+ }
475
521
 
476
522
  return fn;
477
523
  },
@@ -569,20 +615,13 @@ enifed('backburner', ['exports', './backburner/utils', './backburner/platform',
569
615
  },
570
616
 
571
617
  cancelTimers: function () {
572
- var clearItems = function (item) {
573
- clearTimeout(item[2]);
574
- };
575
-
576
618
  _backburnerUtils.each(this._throttlers, clearItems);
577
619
  this._throttlers = [];
578
620
 
579
621
  _backburnerUtils.each(this._debouncees, clearItems);
580
622
  this._debouncees = [];
581
623
 
582
- if (this._laterTimer) {
583
- clearTimeout(this._laterTimer);
584
- this._laterTimer = null;
585
- }
624
+ this._clearTimerTimeout();
586
625
  this._timers = [];
587
626
 
588
627
  if (this._autorun) {
@@ -607,15 +646,7 @@ enifed('backburner', ['exports', './backburner/utils', './backburner/platform',
607
646
  if (this._timers[i + 1] === timer) {
608
647
  this._timers.splice(i, 2); // remove the two elements
609
648
  if (i === 0) {
610
- if (this._laterTimer) {
611
- // Active timer? Then clear timer and reset for future timer
612
- clearTimeout(this._laterTimer);
613
- this._laterTimer = null;
614
- }
615
- if (this._timers.length > 0) {
616
- // Update to next available timer when available
617
- updateLaterTimer(this, this._timers[0], this._timers[0] - _backburnerUtils.now());
618
- }
649
+ this._reinstallTimerTimeout();
619
650
  }
620
651
  return true;
621
652
  }
@@ -649,6 +680,67 @@ enifed('backburner', ['exports', './backburner/utils', './backburner/platform',
649
680
  }
650
681
 
651
682
  return false;
683
+ },
684
+
685
+ _runExpiredTimers: function () {
686
+ this._timerTimeoutId = undefined;
687
+ this.run(this, this._scheduleExpiredTimers);
688
+ },
689
+
690
+ _scheduleExpiredTimers: function () {
691
+ var n = _backburnerUtils.now();
692
+ var timers = this._timers;
693
+ var i = 0;
694
+ var l = timers.length;
695
+ for (; i < l; i += 2) {
696
+ var executeAt = timers[i];
697
+ var fn = timers[i + 1];
698
+ if (executeAt <= n) {
699
+ this.schedule(this.options.defaultQueue, null, fn);
700
+ } else {
701
+ break;
702
+ }
703
+ }
704
+ timers.splice(0, i);
705
+ this._installTimerTimeout();
706
+ },
707
+
708
+ _reinstallStalledTimerTimeout: function () {
709
+ if (!this._timerTimeoutId) {
710
+ return;
711
+ }
712
+ // if we have a timer we should always have a this._timerTimeoutId
713
+ var minExpiresAt = this._timers[0];
714
+ var delay = _backburnerUtils.now() - minExpiresAt;
715
+ // threshold of a second before we assume that the currently
716
+ // installed timeout will not run, so we don't constantly reinstall
717
+ // timeouts that are delayed but good still
718
+ if (delay < TIMEOUT_STALLED_THRESHOLD) {
719
+ return;
720
+ }
721
+ },
722
+
723
+ _reinstallTimerTimeout: function () {
724
+ this._clearTimerTimeout();
725
+ this._installTimerTimeout();
726
+ },
727
+
728
+ _clearTimerTimeout: function () {
729
+ if (!this._timerTimeoutId) {
730
+ return;
731
+ }
732
+ clearTimeout(this._timerTimeoutId);
733
+ this._timerTimeoutId = undefined;
734
+ },
735
+
736
+ _installTimerTimeout: function () {
737
+ if (!this._timers.length) {
738
+ return;
739
+ }
740
+ var minExpiresAt = this._timers[0];
741
+ var n = _backburnerUtils.now();
742
+ var wait = Math.max(0, minExpiresAt - n);
743
+ this._timerTimeoutId = setTimeout(this._boundRunExpiredTimers, wait);
652
744
  }
653
745
  };
654
746
 
@@ -676,52 +768,6 @@ enifed('backburner', ['exports', './backburner/utils', './backburner/platform',
676
768
  });
677
769
  }
678
770
 
679
- function updateLaterTimer(backburner, executeAt, wait) {
680
- var n = _backburnerUtils.now();
681
- if (!backburner._laterTimer || executeAt < backburner._laterTimerExpiresAt || backburner._laterTimerExpiresAt < n) {
682
-
683
- if (backburner._laterTimer) {
684
- // Clear when:
685
- // - Already expired
686
- // - New timer is earlier
687
- clearTimeout(backburner._laterTimer);
688
-
689
- if (backburner._laterTimerExpiresAt < n) {
690
- // If timer was never triggered
691
- // Calculate the left-over wait-time
692
- wait = Math.max(0, executeAt - n);
693
- }
694
- }
695
-
696
- backburner._laterTimer = _backburnerPlatform.default.setTimeout(function () {
697
- backburner._laterTimer = null;
698
- backburner._laterTimerExpiresAt = null;
699
- executeTimers(backburner);
700
- }, wait);
701
-
702
- backburner._laterTimerExpiresAt = n + wait;
703
- }
704
- }
705
-
706
- function executeTimers(backburner) {
707
- var n = _backburnerUtils.now();
708
- var fns, i, l;
709
-
710
- backburner.run(function () {
711
- i = _backburnerBinarySearch.default(n, backburner._timers);
712
-
713
- fns = backburner._timers.splice(0, i);
714
-
715
- for (i = 1, l = fns.length; i < l; i += 2) {
716
- backburner.schedule(backburner.options.defaultQueue, null, fns[i]);
717
- }
718
- });
719
-
720
- if (backburner._timers.length) {
721
- updateLaterTimer(backburner, backburner._timers[0], backburner._timers[0] - n);
722
- }
723
- }
724
-
725
771
  function findDebouncee(target, method, debouncees) {
726
772
  return findItem(target, method, debouncees);
727
773
  }
@@ -744,6 +790,10 @@ enifed('backburner', ['exports', './backburner/utils', './backburner/platform',
744
790
 
745
791
  return index;
746
792
  }
793
+
794
+ function clearItems(item) {
795
+ clearTimeout(item[2]);
796
+ }
747
797
  });
748
798
  enifed("backburner/binary-search", ["exports"], function (exports) {
749
799
  "use strict";
@@ -821,10 +871,9 @@ enifed('backburner/deferred-action-queues', ['exports', './utils', './queue'], f
821
871
  flush: function () {
822
872
  var queues = this.queues;
823
873
  var queueNames = this.queueNames;
824
- var queueName, queue, queueItems, priorQueueNameIndex;
874
+ var queueName, queue;
825
875
  var queueNameIndex = 0;
826
876
  var numberOfQueues = queueNames.length;
827
- var options = this.options;
828
877
 
829
878
  while (queueNameIndex < numberOfQueues) {
830
879
  queueName = queueNames[queueNameIndex];
@@ -948,11 +997,6 @@ enifed('backburner/queue', ['exports', './utils'], function (exports, _utils) {
948
997
  },
949
998
 
950
999
  pushUnique: function (target, method, args, stack) {
951
- var queue = this._queue,
952
- currentTarget,
953
- currentMethod,
954
- i,
955
- l;
956
1000
  var KEY = this.globalOptions.GUID_KEY;
957
1001
 
958
1002
  if (target && KEY) {
@@ -1367,10 +1411,66 @@ enifed('ember-debug', ['exports', 'ember-metal/core', 'ember-metal/assert', 'emb
1367
1411
  }, false);
1368
1412
  }
1369
1413
  }
1370
-
1414
+ /**
1415
+ @public
1416
+ @class Ember.Debug
1417
+ */
1371
1418
  _emberMetalCore.default.Debug = {};
1372
1419
 
1420
+ /**
1421
+ Allows for runtime registration of handler functions that override the default deprecation behavior.
1422
+ Deprecations are invoked by calls to [Ember.deprecate](http://emberjs.com/api/classes/Ember.html#method_deprecate).
1423
+ The following example demonstrates its usage by registering a handler that throws an error if the
1424
+ message contains the word "should", otherwise defers to the default handler.
1425
+ ```javascript
1426
+ Ember.Debug.registerDeprecationHandler((message, options, next) => {
1427
+ if (message.indexOf('should') !== -1) {
1428
+ throw new Error(`Deprecation message with should: ${message}`);
1429
+ } else {
1430
+ // defer to whatever handler was registered before this one
1431
+ next(message, options);
1432
+ }
1433
+ }
1434
+ ```
1435
+ The handler function takes the following arguments:
1436
+ <ul>
1437
+ <li> <code>message</code> - The message received from the deprecation call. </li>
1438
+ <li> <code>options</code> - An object passed in with the deprecation call containing additional information including:</li>
1439
+ <ul>
1440
+ <li> <code>id</code> - an id of the deprecation in the form of <code>package-name.specific-deprecation</code>.</li>
1441
+ <li> <code>until</code> - is the version number Ember the feature and deprecation will be removed in.</li>
1442
+ </ul>
1443
+ <li> <code>next</code> - a function that calls into the previously registered handler.</li>
1444
+ </ul>
1445
+ @public
1446
+ @static
1447
+ @method registerDeprecationHandler
1448
+ @param handler {Function} a function to handle deprecation calls
1449
+ */
1373
1450
  _emberMetalCore.default.Debug.registerDeprecationHandler = _emberDebugDeprecate.registerHandler;
1451
+ /**
1452
+ Allows for runtime registration of handler functions that override the default warning behavior.
1453
+ Warnings are invoked by calls made to [Ember.warn](http://emberjs.com/api/classes/Ember.html#method_warn).
1454
+ The following example demonstrates its usage by registering a handler that does nothing overriding Ember's
1455
+ default warning behavior.
1456
+ ```javascript
1457
+ // next is not called, so no warnings get the default behavior
1458
+ Ember.Debug.registerWarnHandler(() => {});
1459
+ ```
1460
+ The handler function takes the following arguments:
1461
+ <ul>
1462
+ <li> <code>message</code> - The message received from the warn call. </li>
1463
+ <li> <code>options</code> - An object passed in with the warn call containing additional information including:</li>
1464
+ <ul>
1465
+ <li> <code>id</code> - an id of the warning in the form of <code>package-name.specific-warning</code>.</li>
1466
+ </ul>
1467
+ <li> <code>next</code> - a function that calls into the previously registered handler.</li>
1468
+ </ul>
1469
+ @public
1470
+ @static
1471
+ @method registerWarnHandler
1472
+ @param handler {Function} a function to handle warnings
1473
+ */
1374
1474
  _emberMetalCore.default.Debug.registerWarnHandler = _emberDebugWarn.registerHandler;
1375
1475
 
1376
1476
  /*
@@ -1491,15 +1591,27 @@ enifed('ember-debug/deprecate', ['exports', 'ember-metal/core', 'ember-metal/err
1491
1591
 
1492
1592
  function deprecate(message, test, options) {
1493
1593
  if (!options || !options.id && !options.until) {
1494
- deprecate(missingOptionsDeprecation, false, { id: 'ember-debug.deprecate-options-missing', until: '3.0.0' });
1594
+ deprecate(missingOptionsDeprecation, false, {
1595
+ id: 'ember-debug.deprecate-options-missing',
1596
+ until: '3.0.0',
1597
+ url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options'
1598
+ });
1495
1599
  }
1496
1600
 
1497
1601
  if (options && !options.id) {
1498
- deprecate(missingOptionsIdDeprecation, false, { id: 'ember-debug.deprecate-id-missing', until: '3.0.0' });
1602
+ deprecate(missingOptionsIdDeprecation, false, {
1603
+ id: 'ember-debug.deprecate-id-missing',
1604
+ until: '3.0.0',
1605
+ url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options'
1606
+ });
1499
1607
  }
1500
1608
 
1501
1609
  if (options && !options.until) {
1502
- deprecate(missingOptionsUntilDeprecation, options && options.until, { id: 'ember-debug.deprecate-until-missing', until: '3.0.0' });
1610
+ deprecate(missingOptionsUntilDeprecation, options && options.until, {
1611
+ id: 'ember-debug.deprecate-until-missing',
1612
+ until: '3.0.0',
1613
+ url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options'
1614
+ });
1503
1615
  }
1504
1616
 
1505
1617
  _emberDebugHandlers.invoke.apply(undefined, ['deprecate'].concat(_slice.call(arguments)));
@@ -1586,11 +1698,19 @@ enifed('ember-debug/warn', ['exports', 'ember-metal/core', 'ember-metal/logger',
1586
1698
 
1587
1699
  function warn(message, test, options) {
1588
1700
  if (!options) {
1589
- _emberMetalCore.default.deprecate(missingOptionsDeprecation, false, { id: 'ember-debug.warn-options-missing', until: '3.0.0' });
1701
+ _emberMetalCore.default.deprecate(missingOptionsDeprecation, false, {
1702
+ id: 'ember-debug.warn-options-missing',
1703
+ until: '3.0.0',
1704
+ url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options'
1705
+ });
1590
1706
  }
1591
1707
 
1592
1708
  if (options && !options.id) {
1593
- _emberMetalCore.default.deprecate(missingOptionsIdDeprecation, false, { id: 'ember-debug.warn-id-missing', until: '3.0.0' });
1709
+ _emberMetalCore.default.deprecate(missingOptionsIdDeprecation, false, {
1710
+ id: 'ember-debug.warn-id-missing',
1711
+ until: '3.0.0',
1712
+ url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options'
1713
+ });
1594
1714
  }
1595
1715
 
1596
1716
  _emberDebugHandlers.invoke.apply(undefined, ['warn'].concat(_slice.call(arguments)));
@@ -3610,36 +3730,35 @@ enifed('ember-metal/computed', ['exports', 'ember-metal/core', 'ember-metal/prop
3610
3730
  //
3611
3731
 
3612
3732
  /**
3613
- A computed property transforms an object's function into a property.
3733
+ A computed property transforms an object literal with object's accessor function(s) into a property.
3614
3734
 
3615
3735
  By default the function backing the computed property will only be called
3616
3736
  once and the result will be cached. You can specify various properties
3617
3737
  that your computed property depends on. This will force the cached
3618
3738
  result to be recomputed if the dependencies are modified.
3619
3739
 
3620
- In the following example we declare a computed property (by calling
3621
- `.property()` on the fullName function) and setup the property
3622
- dependencies (depending on firstName and lastName). The fullName function
3740
+ In the following example we declare a computed property - `fullName` - by calling
3741
+ `.Ember.computed()` with property dependencies (`firstName` and `lastName`) as leading arguments and getter accessor function. The `fullName` getter function
3623
3742
  will be called once (regardless of how many times it is accessed) as long
3624
- as its dependencies have not changed. Once firstName or lastName are updated
3625
- any future calls (or anything bound) to fullName will incorporate the new
3743
+ as its dependencies have not changed. Once `firstName` or `lastName` are updated
3744
+ any future calls (or anything bound) to `fullName` will incorporate the new
3626
3745
  values.
3627
3746
 
3628
3747
  ```javascript
3629
- var Person = Ember.Object.extend({
3748
+ let Person = Ember.Object.extend({
3630
3749
  // these will be supplied by `create`
3631
3750
  firstName: null,
3632
3751
  lastName: null,
3633
3752
 
3634
- fullName: function() {
3635
- var firstName = this.get('firstName');
3636
- var lastName = this.get('lastName');
3753
+ fullName: Ember.computed('firstName', 'lastName', function() {
3754
+ let firstName = this.get('firstName'),
3755
+ lastName = this.get('lastName');
3637
3756
 
3638
- return firstName + ' ' + lastName;
3639
- }.property('firstName', 'lastName')
3757
+ return firstName + ' ' + lastName;
3758
+ })
3640
3759
  });
3641
3760
 
3642
- var tom = Person.create({
3761
+ let tom = Person.create({
3643
3762
  firstName: 'Tom',
3644
3763
  lastName: 'Dale'
3645
3764
  });
@@ -3647,44 +3766,69 @@ enifed('ember-metal/computed', ['exports', 'ember-metal/core', 'ember-metal/prop
3647
3766
  tom.get('fullName') // 'Tom Dale'
3648
3767
  ```
3649
3768
 
3650
- You can also define what Ember should do when setting a computed property.
3651
- If you try to set a computed property, it will be invoked with the key and
3652
- value you want to set it to. You can also accept the previous value as the
3653
- third parameter.
3769
+ You can also define what Ember should do when setting a computed property by providing additional function (`set`) in hash argument.
3770
+ If you try to set a computed property, it will try to invoke setter accessor function with the key and
3771
+ value you want to set it to as arguments.
3654
3772
 
3655
3773
  ```javascript
3656
- var Person = Ember.Object.extend({
3774
+ let Person = Ember.Object.extend({
3657
3775
  // these will be supplied by `create`
3658
3776
  firstName: null,
3659
3777
  lastName: null,
3660
3778
 
3661
- fullName: function(key, value, oldValue) {
3662
- // getter
3663
- if (arguments.length === 1) {
3664
- var firstName = this.get('firstName');
3665
- var lastName = this.get('lastName');
3779
+ fullName: Ember.computed('firstName', 'lastName', {
3780
+ get(key) {
3781
+ let firstName = this.get('firstName'),
3782
+ lastName = this.get('lastName');
3666
3783
 
3667
3784
  return firstName + ' ' + lastName;
3785
+ },
3786
+ set(key, value) {
3787
+ let [firstName, lastName] = value.split(' ');
3668
3788
 
3669
- // setter
3670
- } else {
3671
- var name = value.split(' ');
3672
-
3673
- this.set('firstName', name[0]);
3674
- this.set('lastName', name[1]);
3789
+ this.set('firstName', firstName);
3790
+ this.set('lastName', lastName);
3675
3791
 
3676
3792
  return value;
3677
3793
  }
3678
- }.property('firstName', 'lastName')
3794
+ })
3679
3795
  });
3680
3796
 
3681
- var person = Person.create();
3797
+ let person = Person.create();
3682
3798
 
3683
3799
  person.set('fullName', 'Peter Wagenet');
3684
3800
  person.get('firstName'); // 'Peter'
3685
3801
  person.get('lastName'); // 'Wagenet'
3686
3802
  ```
3687
3803
 
3804
+ You can overwrite computed property with normal property (no longer computed), that won't change if dependencies change, if you set computed property and it won't have setter accessor function defined.
3805
+
3806
+ You can also mark computed property as `.readOnly()` and block all attempts to set it.
3807
+
3808
+ ```javascript
3809
+ let Person = Ember.Object.extend({
3810
+ // these will be supplied by `create`
3811
+ firstName: null,
3812
+ lastName: null,
3813
+
3814
+ fullName: Ember.computed('firstName', 'lastName', {
3815
+ get(key) {
3816
+ let firstName = this.get('firstName');
3817
+ let lastName = this.get('lastName');
3818
+
3819
+ return firstName + ' ' + lastName;
3820
+ }
3821
+ }).readOnly()
3822
+ });
3823
+
3824
+ let person = Person.create();
3825
+ person.set('fullName', 'Peter Wagenet'); // Uncaught Error: Cannot set read-only property "fullName" on object: <(...):emberXXX>
3826
+ ```
3827
+
3828
+ Additional resources:
3829
+ - [New CP syntax RFC](https://github.com/emberjs/rfcs/blob/master/text/0011-improved-cp-syntax.md)
3830
+ - [New computed syntax explained in "Ember 1.12 released" ](http://emberjs.com/blog/2015/05/13/ember-1-12-released.html#toc_new-computed-syntax)
3831
+
3688
3832
  @class ComputedProperty
3689
3833
  @namespace Ember
3690
3834
  @constructor
@@ -3732,10 +3876,10 @@ enifed('ember-metal/computed', ['exports', 'ember-metal/core', 'ember-metal/prop
3732
3876
  invalidation and notification when cached value is invalidated.
3733
3877
 
3734
3878
  ```javascript
3735
- var outsideService = Ember.Object.extend({
3736
- value: function() {
3879
+ let outsideService = Ember.Object.extend({
3880
+ value: Ember.computed(function() {
3737
3881
  return OutsideService.getValue();
3738
- }.property().volatile()
3882
+ }).volatile()
3739
3883
  }).create();
3740
3884
  ```
3741
3885
 
@@ -3754,13 +3898,13 @@ enifed('ember-metal/computed', ['exports', 'ember-metal/core', 'ember-metal/prop
3754
3898
  mode the computed property will throw an error when set.
3755
3899
 
3756
3900
  ```javascript
3757
- var Person = Ember.Object.extend({
3758
- guid: function() {
3901
+ let Person = Ember.Object.extend({
3902
+ guid: Ember.computed(function() {
3759
3903
  return 'guid-guid-guid';
3760
- }.property().readOnly()
3904
+ }).readOnly()
3761
3905
  });
3762
3906
 
3763
- var person = Person.create();
3907
+ let person = Person.create();
3764
3908
 
3765
3909
  person.set('guid', 'new-guid'); // will throw an exception
3766
3910
  ```
@@ -3781,8 +3925,8 @@ enifed('ember-metal/computed', ['exports', 'ember-metal/core', 'ember-metal/prop
3781
3925
  arguments containing key paths that this computed property depends on.
3782
3926
 
3783
3927
  ```javascript
3784
- var President = Ember.Object.extend({
3785
- fullName: computed(function() {
3928
+ let President = Ember.Object.extend({
3929
+ fullName: Ember.computed(function() {
3786
3930
  return this.get('firstName') + ' ' + this.get('lastName');
3787
3931
 
3788
3932
  // Tell Ember that this computed property depends on firstName
@@ -3790,7 +3934,7 @@ enifed('ember-metal/computed', ['exports', 'ember-metal/core', 'ember-metal/prop
3790
3934
  }).property('firstName', 'lastName')
3791
3935
  });
3792
3936
 
3793
- var president = President.create({
3937
+ let president = President.create({
3794
3938
  firstName: 'Barack',
3795
3939
  lastName: 'Obama'
3796
3940
  });
@@ -3830,10 +3974,10 @@ enifed('ember-metal/computed', ['exports', 'ember-metal/core', 'ember-metal/prop
3830
3974
  You can pass a hash of these values to a computed property like this:
3831
3975
 
3832
3976
  ```
3833
- person: function() {
3834
- var personId = this.get('personId');
3977
+ person: Ember.computed(function() {
3978
+ let personId = this.get('personId');
3835
3979
  return App.Person.create({ id: personId });
3836
- }.property().meta({ type: App.Person })
3980
+ }).meta({ type: App.Person })
3837
3981
  ```
3838
3982
 
3839
3983
  The hash that you pass to the `meta()` function will be saved on the
@@ -3883,15 +4027,15 @@ enifed('ember-metal/computed', ['exports', 'ember-metal/core', 'ember-metal/prop
3883
4027
  Otherwise, call the function passing the property name as an argument.
3884
4028
 
3885
4029
  ```javascript
3886
- var Person = Ember.Object.extend({
3887
- fullName: function(keyName) {
4030
+ let Person = Ember.Object.extend({
4031
+ fullName: Ember.computed('firstName', 'lastName', function(keyName) {
3888
4032
  // the keyName parameter is 'fullName' in this case.
3889
4033
  return this.get('firstName') + ' ' + this.get('lastName');
3890
- }.property('firstName', 'lastName')
4034
+ })
3891
4035
  });
3892
4036
 
3893
4037
 
3894
- var tom = Person.create({
4038
+ let tom = Person.create({
3895
4039
  firstName: 'Tom',
3896
4040
  lastName: 'Dale'
3897
4041
  });
@@ -3942,35 +4086,35 @@ enifed('ember-metal/computed', ['exports', 'ember-metal/core', 'ember-metal/prop
3942
4086
  the value of the property to the value being set.
3943
4087
 
3944
4088
  Generally speaking if you intend for your computed property to be set
3945
- your backing function should accept either two or three arguments.
4089
+ you should pass `set(key, value)` function in hash as argument to `Ember.computed()` along with `get(key)` function.
3946
4090
 
3947
4091
  ```javascript
3948
- var Person = Ember.Object.extend({
4092
+ let Person = Ember.Object.extend({
3949
4093
  // these will be supplied by `create`
3950
4094
  firstName: null,
3951
4095
  lastName: null,
3952
4096
 
3953
- fullName: function(key, value, oldValue) {
4097
+ fullName: Ember.computed('firstName', 'lastName', {
3954
4098
  // getter
3955
- if (arguments.length === 1) {
3956
- var firstName = this.get('firstName');
3957
- var lastName = this.get('lastName');
4099
+ get() {
4100
+ let firstName = this.get('firstName');
4101
+ let lastName = this.get('lastName');
3958
4102
 
3959
4103
  return firstName + ' ' + lastName;
3960
-
4104
+ },
3961
4105
  // setter
3962
- } else {
3963
- var name = value.split(' ');
4106
+ set(key, value) {
4107
+ let [firstName, lastName] = value.split(' ');
3964
4108
 
3965
- this.set('firstName', name[0]);
3966
- this.set('lastName', name[1]);
4109
+ this.set('firstName', firstName);
4110
+ this.set('lastName', lastName);
3967
4111
 
3968
4112
  return value;
3969
4113
  }
3970
- }.property('firstName', 'lastName')
4114
+ })
3971
4115
  });
3972
4116
 
3973
- var person = Person.create();
4117
+ let person = Person.create();
3974
4118
 
3975
4119
  person.set('fullName', 'Peter Wagenet');
3976
4120
  person.get('firstName'); // 'Peter'
@@ -3980,7 +4124,6 @@ enifed('ember-metal/computed', ['exports', 'ember-metal/core', 'ember-metal/prop
3980
4124
  @method set
3981
4125
  @param {String} keyName The key being accessed.
3982
4126
  @param {Object} newValue The new value being assigned.
3983
- @param {String} oldValue The old value being replaced.
3984
4127
  @return {Object} The return value of the function backing the CP.
3985
4128
  @public
3986
4129
  */
@@ -4090,24 +4233,26 @@ enifed('ember-metal/computed', ['exports', 'ember-metal/core', 'ember-metal/prop
4090
4233
  computed property function. You can use this helper to define properties
4091
4234
  with mixins or via `Ember.defineProperty()`.
4092
4235
 
4093
- The function you pass will be used to both get and set property values.
4094
- The function should accept two parameters, key and value. If value is not
4095
- undefined you should set the value first. In either case return the
4236
+ If you pass function as argument - it will be used as getter.
4237
+ You can pass hash with two functions - instead of single function - as argument to provide both getter and setter.
4238
+
4239
+ The `get` function should accept two parameters, `key` and `value`. If `value` is not
4240
+ undefined you should set the `value` first. In either case return the
4096
4241
  current value of the property.
4097
4242
 
4098
4243
  A computed property defined in this way might look like this:
4099
4244
 
4100
4245
  ```js
4101
- var Person = Ember.Object.extend({
4246
+ let Person = Ember.Object.extend({
4102
4247
  firstName: 'Betty',
4103
4248
  lastName: 'Jones',
4104
4249
 
4105
- fullName: Ember.computed('firstName', 'lastName', function(key, value) {
4250
+ fullName: Ember.computed('firstName', 'lastName', function() {
4106
4251
  return this.get('firstName') + ' ' + this.get('lastName');
4107
4252
  })
4108
4253
  });
4109
4254
 
4110
- var client = Person.create();
4255
+ let client = Person.create();
4111
4256
 
4112
4257
  client.get('fullName'); // 'Betty Jones'
4113
4258
 
@@ -4125,7 +4270,7 @@ enifed('ember-metal/computed', ['exports', 'ember-metal/core', 'ember-metal/prop
4125
4270
  (if prototype extensions are enabled, which is the default behavior):
4126
4271
 
4127
4272
  ```js
4128
- fullName: function () {
4273
+ fullName() {
4129
4274
  return this.get('firstName') + ' ' + this.get('lastName');
4130
4275
  }.property('firstName', 'lastName')
4131
4276
  ```
@@ -4229,7 +4374,7 @@ enifed('ember-metal/core', ['exports', 'ember-metal/assert'], function (exports,
4229
4374
 
4230
4375
  @class Ember
4231
4376
  @static
4232
- @version 2.1.0-beta.3
4377
+ @version 2.1.0
4233
4378
  @public
4234
4379
  */
4235
4380
 
@@ -4263,11 +4408,11 @@ enifed('ember-metal/core', ['exports', 'ember-metal/assert'], function (exports,
4263
4408
 
4264
4409
  @property VERSION
4265
4410
  @type String
4266
- @default '2.1.0-beta.3'
4411
+ @default '2.1.0'
4267
4412
  @static
4268
4413
  @public
4269
4414
  */
4270
- Ember.VERSION = '2.1.0-beta.3';
4415
+ Ember.VERSION = '2.1.0';
4271
4416
 
4272
4417
  /**
4273
4418
  The hash of environment variables used to control various configuration
@@ -10701,7 +10846,7 @@ enifed('ember-metal/utils', ['exports'], function (exports) {
10701
10846
 
10702
10847
  You can also use this method on DOM Element objects.
10703
10848
 
10704
- @private
10849
+ @public
10705
10850
  @method guidFor
10706
10851
  @for Ember
10707
10852
  @param {Object} obj any object, string, number, Element, or primitive
@@ -10774,6 +10919,8 @@ enifed('ember-metal/utils', ['exports'], function (exports) {
10774
10919
  }
10775
10920
  }
10776
10921
 
10922
+ var HAS_SUPER_PATTERN = /\.(_super|call\(this|apply\(this)/;
10923
+
10777
10924
  var checkHasSuper = (function () {
10778
10925
  var sourceAvailable = (function () {
10779
10926
  return this;
@@ -10781,7 +10928,7 @@ enifed('ember-metal/utils', ['exports'], function (exports) {
10781
10928
 
10782
10929
  if (sourceAvailable) {
10783
10930
  return function checkHasSuper(func) {
10784
- return func.toString().indexOf('_super') > -1;
10931
+ return HAS_SUPER_PATTERN.test(func.toString());
10785
10932
  };
10786
10933
  }
10787
10934
 
@@ -12347,7 +12494,7 @@ enifed('ember-template-compiler/system/compile_options', ['exports', 'ember-meta
12347
12494
  options.buildMeta = function buildMeta(program) {
12348
12495
  return {
12349
12496
  topLevel: detectTopLevel(program),
12350
- revision: 'Ember@2.1.0-beta.3',
12497
+ revision: 'Ember@2.1.0',
12351
12498
  loc: program.loc,
12352
12499
  moduleName: options.moduleName
12353
12500
  };