ember-source 4.3.0-alpha.1 → 4.3.0-beta.1
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.
- package/CHANGELOG.md +6 -2
- package/blueprints/component-addon/index.js +2 -3
- package/blueprints/component-class-addon/index.js +2 -3
- package/blueprints/controller/files/__root__/__path__/__name__.js +2 -2
- package/blueprints/controller/index.js +2 -4
- package/blueprints/route/files/__root__/__path__/__name__.js +3 -3
- package/blueprints/route/index.js +2 -3
- package/blueprints/service/files/__root__/__path__/__name__.js +2 -2
- package/blueprints/service/index.js +2 -4
- package/build-metadata.json +3 -3
- package/dist/dependencies/router_js.js +66 -31
- package/dist/ember-template-compiler.js +1250 -861
- package/dist/ember-template-compiler.map +1 -1
- package/dist/ember-testing.js +88 -56
- package/dist/ember-testing.map +1 -1
- package/dist/ember.debug.js +3712 -3159
- package/dist/ember.debug.map +1 -1
- package/dist/header/license.js +1 -1
- package/dist/header/loader.js +0 -1
- package/dist/packages/@ember/-internals/bootstrap/index.js +0 -2
- package/dist/packages/@ember/-internals/container/index.js +16 -11
- package/dist/packages/@ember/-internals/extension-support/lib/container_debug_adapter.js +3 -3
- package/dist/packages/@ember/-internals/extension-support/lib/data_adapter.js +52 -52
- package/dist/packages/@ember/-internals/glimmer/index.js +161 -125
- package/dist/packages/@ember/-internals/meta/lib/meta.js +67 -11
- package/dist/packages/@ember/-internals/metal/index.js +95 -121
- package/dist/packages/@ember/-internals/routing/lib/ext/controller.js +24 -12
- package/dist/packages/@ember/-internals/routing/lib/location/api.js +1 -0
- package/dist/packages/@ember/-internals/routing/lib/location/auto_location.js +3 -1
- package/dist/packages/@ember/-internals/routing/lib/services/router.js +117 -197
- package/dist/packages/@ember/-internals/routing/lib/services/routing.js +3 -1
- package/dist/packages/@ember/-internals/routing/lib/system/route-info.js +2 -2
- package/dist/packages/@ember/-internals/routing/lib/system/route.js +147 -402
- package/dist/packages/@ember/-internals/routing/lib/system/router.js +82 -40
- package/dist/packages/@ember/-internals/routing/lib/utils.js +48 -25
- package/dist/packages/@ember/-internals/runtime/lib/mixins/-proxy.js +1 -1
- package/dist/packages/@ember/-internals/runtime/lib/mixins/array.js +1 -0
- package/dist/packages/@ember/-internals/runtime/lib/mixins/comparable.js +4 -4
- package/dist/packages/@ember/-internals/runtime/lib/mixins/container_proxy.js +29 -29
- package/dist/packages/@ember/-internals/runtime/lib/mixins/promise_proxy.js +16 -16
- package/dist/packages/@ember/-internals/runtime/lib/mixins/registry_proxy.js +48 -48
- package/dist/packages/@ember/-internals/runtime/lib/mixins/target_action_support.js +8 -8
- package/dist/packages/@ember/-internals/runtime/lib/system/namespace.js +1 -2
- package/dist/packages/@ember/-internals/runtime/lib/type-of.js +1 -1
- package/dist/packages/@ember/-internals/utils/index.js +11 -9
- package/dist/packages/@ember/-internals/views/lib/mixins/view_support.js +2 -4
- package/dist/packages/@ember/-internals/views/lib/system/utils.js +2 -0
- package/dist/packages/@ember/application/lib/application.js +0 -2
- package/dist/packages/@ember/array/index.js +1 -1
- package/dist/packages/@ember/canary-features/index.js +2 -2
- package/dist/packages/@ember/controller/index.js +3 -54
- package/dist/packages/@ember/debug/index.js +1 -1
- package/dist/packages/@ember/debug/lib/deprecate.js +12 -10
- package/dist/packages/@ember/instrumentation/index.js +9 -13
- package/dist/packages/@ember/object/compat.js +16 -7
- package/dist/packages/@ember/polyfills/lib/assign.js +1 -0
- package/dist/packages/@ember/routing/router-service.js +1 -0
- package/dist/packages/@ember/runloop/index.js +9 -9
- package/dist/packages/@ember/service/index.js +6 -73
- package/dist/packages/@ember/string/index.js +1 -0
- package/dist/packages/ember/index.js +1 -2
- package/dist/packages/ember/version.js +1 -1
- package/docs/data.json +2588 -1839
- package/package.json +27 -27
- package/blueprints/component-addon/native-files/__root__/__path__/__name__.js +0 -1
- package/blueprints/component-class-addon/native-files/__root__/__path__/__name__.js +0 -1
- package/blueprints/controller/native-files/__root__/__path__/__name__.js +0 -4
- package/blueprints/edition-detector.js +0 -13
- package/blueprints/route/native-files/__root__/__path__/__name__.js +0 -11
- package/blueprints/route/native-files/__root__/__templatepath__/__templatename__.hbs +0 -2
- package/blueprints/service/native-files/__root__/__path__/__name__.js +0 -4
|
@@ -685,8 +685,7 @@ function finishLazyChains(meta$$1, key, value) {
|
|
|
685
685
|
}
|
|
686
686
|
|
|
687
687
|
if (isObject(value)) {
|
|
688
|
-
for (let
|
|
689
|
-
let [tag, deps] = lazyTags[i];
|
|
688
|
+
for (let [tag, deps] of lazyTags) {
|
|
690
689
|
updateTag(tag, getChainTagsForKey(value, deps, tagMetaFor(value), peekMeta(value)));
|
|
691
690
|
}
|
|
692
691
|
}
|
|
@@ -696,8 +695,8 @@ function finishLazyChains(meta$$1, key, value) {
|
|
|
696
695
|
function getChainTagsForKeys(obj, keys, tagMeta, meta$$1) {
|
|
697
696
|
let tags = [];
|
|
698
697
|
|
|
699
|
-
for (let
|
|
700
|
-
getChainTags(tags, obj,
|
|
698
|
+
for (let key of keys) {
|
|
699
|
+
getChainTags(tags, obj, key, tagMeta, meta$$1);
|
|
701
700
|
}
|
|
702
701
|
|
|
703
702
|
return combine(tags);
|
|
@@ -759,7 +758,6 @@ function getChainTags(chainTags, obj, path, tagMeta, meta$$1) {
|
|
|
759
758
|
descriptor = currentMeta !== null ? currentMeta.peekDescriptors(segment) : undefined; // If the key is an alias, we need to bootstrap it
|
|
760
759
|
|
|
761
760
|
if (descriptor !== undefined && typeof descriptor.altKey === 'string') {
|
|
762
|
-
// tslint:disable-next-line: no-unused-expression
|
|
763
761
|
item[segment];
|
|
764
762
|
}
|
|
765
763
|
}
|
|
@@ -781,7 +779,6 @@ function getChainTags(chainTags, obj, path, tagMeta, meta$$1) {
|
|
|
781
779
|
// bootstrap the alias. This is because aliases, unlike other CPs, should
|
|
782
780
|
// always be in sync with the aliased value.
|
|
783
781
|
if (CHAIN_PASS_THROUGH.has(descriptor)) {
|
|
784
|
-
// tslint:disable-next-line: no-unused-expression
|
|
785
782
|
current[segment];
|
|
786
783
|
}
|
|
787
784
|
|
|
@@ -1315,8 +1312,8 @@ class ComputedProperty extends ComputedDescriptor {
|
|
|
1315
1312
|
args.push(property);
|
|
1316
1313
|
}
|
|
1317
1314
|
|
|
1318
|
-
for (let
|
|
1319
|
-
expandProperties(
|
|
1315
|
+
for (let arg of passedArgs) {
|
|
1316
|
+
expandProperties(arg, addArg);
|
|
1320
1317
|
}
|
|
1321
1318
|
|
|
1322
1319
|
this._dependentKeys = args;
|
|
@@ -1585,11 +1582,15 @@ class ComputedDecoratorImpl extends Function {
|
|
|
1585
1582
|
} // TODO: Remove this when we can provide alternatives in the ecosystem to
|
|
1586
1583
|
// addons such as ember-macro-helpers that use it.
|
|
1587
1584
|
|
|
1585
|
+
/** @internal */
|
|
1586
|
+
|
|
1588
1587
|
|
|
1589
1588
|
get _getter() {
|
|
1590
1589
|
return descriptorForDecorator(this)._getter;
|
|
1591
1590
|
} // TODO: Refactor this, this is an internal API only
|
|
1592
1591
|
|
|
1592
|
+
/** @internal */
|
|
1593
|
+
|
|
1593
1594
|
|
|
1594
1595
|
set enumerable(value) {
|
|
1595
1596
|
descriptorForDecorator(this).enumerable = value;
|
|
@@ -1601,13 +1602,16 @@ function computed(...args) {
|
|
|
1601
1602
|
assert(`@computed can only be used directly as a native decorator. If you're using tracked in classic classes, add parenthesis to call it like a function: computed()`, !(isElementDescriptor(args.slice(0, 3)) && args.length === 5 && args[4] === true));
|
|
1602
1603
|
|
|
1603
1604
|
if (isElementDescriptor(args)) {
|
|
1605
|
+
// SAFETY: We passed in the impl for this class
|
|
1604
1606
|
let decorator = makeComputedDecorator(new ComputedProperty([]), ComputedDecoratorImpl);
|
|
1605
1607
|
return decorator(args[0], args[1], args[2]);
|
|
1606
|
-
}
|
|
1608
|
+
} // SAFETY: We passed in the impl for this class
|
|
1609
|
+
|
|
1607
1610
|
|
|
1608
1611
|
return makeComputedDecorator(new ComputedProperty(args), ComputedDecoratorImpl);
|
|
1609
1612
|
}
|
|
1610
1613
|
function autoComputed(...config) {
|
|
1614
|
+
// SAFETY: We passed in the impl for this class
|
|
1611
1615
|
return makeComputedDecorator(new AutoComputedProperty(config), ComputedDecoratorImpl);
|
|
1612
1616
|
}
|
|
1613
1617
|
/**
|
|
@@ -1633,6 +1637,8 @@ function getCachedValueFor(obj, key) {
|
|
|
1633
1637
|
|
|
1634
1638
|
if (meta$$1) {
|
|
1635
1639
|
return meta$$1.valueFor(key);
|
|
1640
|
+
} else {
|
|
1641
|
+
return undefined;
|
|
1636
1642
|
}
|
|
1637
1643
|
}
|
|
1638
1644
|
|
|
@@ -1766,45 +1772,7 @@ if (DEBUG) {
|
|
|
1766
1772
|
return Reflect.get(content, keyName, obj);
|
|
1767
1773
|
}
|
|
1768
1774
|
};
|
|
1769
|
-
}
|
|
1770
|
-
// GET AND SET
|
|
1771
|
-
//
|
|
1772
|
-
// If we are on a platform that supports accessors we can use those.
|
|
1773
|
-
// Otherwise simulate accessors by looking up the property directly on the
|
|
1774
|
-
// object.
|
|
1775
|
-
|
|
1776
|
-
/**
|
|
1777
|
-
Gets the value of a property on an object. If the property is computed,
|
|
1778
|
-
the function will be invoked. If the property is not defined but the
|
|
1779
|
-
object implements the `unknownProperty` method then that will be invoked.
|
|
1780
|
-
|
|
1781
|
-
```javascript
|
|
1782
|
-
import { get } from '@ember/object';
|
|
1783
|
-
get(obj, "name");
|
|
1784
|
-
```
|
|
1785
|
-
|
|
1786
|
-
If you plan to run on IE8 and older browsers then you should use this
|
|
1787
|
-
method anytime you want to retrieve a property on an object that you don't
|
|
1788
|
-
know for sure is private. (Properties beginning with an underscore '_'
|
|
1789
|
-
are considered private.)
|
|
1790
|
-
|
|
1791
|
-
On all newer browsers, you only need to use this method to retrieve
|
|
1792
|
-
properties if the property might not be defined on the object and you want
|
|
1793
|
-
to respect the `unknownProperty` handler. Otherwise you can ignore this
|
|
1794
|
-
method.
|
|
1795
|
-
|
|
1796
|
-
Note that if the object itself is `undefined`, this method will throw
|
|
1797
|
-
an error.
|
|
1798
|
-
|
|
1799
|
-
@method get
|
|
1800
|
-
@for @ember/object
|
|
1801
|
-
@static
|
|
1802
|
-
@param {Object} obj The object to retrieve from.
|
|
1803
|
-
@param {String} keyName The property key to retrieve
|
|
1804
|
-
@return {Object} the property value or `null`.
|
|
1805
|
-
@public
|
|
1806
|
-
*/
|
|
1807
|
-
|
|
1775
|
+
}
|
|
1808
1776
|
|
|
1809
1777
|
function get(obj, keyName) {
|
|
1810
1778
|
assert(`Get must be called with two arguments; an object and a property key`, arguments.length === 2);
|
|
@@ -1850,12 +1818,12 @@ function _getPath(root, path) {
|
|
|
1850
1818
|
let obj = root;
|
|
1851
1819
|
let parts = typeof path === 'string' ? path.split('.') : path;
|
|
1852
1820
|
|
|
1853
|
-
for (let
|
|
1821
|
+
for (let part of parts) {
|
|
1854
1822
|
if (obj === undefined || obj === null || obj.isDestroyed) {
|
|
1855
1823
|
return undefined;
|
|
1856
1824
|
}
|
|
1857
1825
|
|
|
1858
|
-
obj = _getProp(obj,
|
|
1826
|
+
obj = _getProp(obj, part);
|
|
1859
1827
|
}
|
|
1860
1828
|
|
|
1861
1829
|
return obj;
|
|
@@ -2007,7 +1975,8 @@ function trySet(root, path, value) {
|
|
|
2007
1975
|
}
|
|
2008
1976
|
|
|
2009
1977
|
function alias(altKey) {
|
|
2010
|
-
assert('You attempted to use @alias as a decorator directly, but it requires a `altKey` parameter', !isElementDescriptor(Array.prototype.slice.call(arguments)));
|
|
1978
|
+
assert('You attempted to use @alias as a decorator directly, but it requires a `altKey` parameter', !isElementDescriptor(Array.prototype.slice.call(arguments))); // SAFETY: We passed in the impl for this class
|
|
1979
|
+
|
|
2011
1980
|
return makeComputedDecorator(new AliasedProperty(altKey), AliasDecoratorImpl);
|
|
2012
1981
|
} // TODO: This class can be svelted once `meta` has been deprecated
|
|
2013
1982
|
|
|
@@ -2083,7 +2052,6 @@ class AliasedProperty extends ComputedDescriptor {
|
|
|
2083
2052
|
}
|
|
2084
2053
|
|
|
2085
2054
|
function AliasedProperty_readOnlySet(obj, keyName) {
|
|
2086
|
-
// eslint-disable-line no-unused-vars
|
|
2087
2055
|
throw new EmberError(`Cannot set read-only property '${keyName}' on object: ${inspect(obj)}`);
|
|
2088
2056
|
}
|
|
2089
2057
|
|
|
@@ -2347,11 +2315,10 @@ class Libraries {
|
|
|
2347
2315
|
|
|
2348
2316
|
_getLibraryByName(name) {
|
|
2349
2317
|
let libs = this._registry;
|
|
2350
|
-
let count = libs.length;
|
|
2351
2318
|
|
|
2352
|
-
for (let
|
|
2353
|
-
if (
|
|
2354
|
-
return
|
|
2319
|
+
for (let lib of libs) {
|
|
2320
|
+
if (lib.name === name) {
|
|
2321
|
+
return lib;
|
|
2355
2322
|
}
|
|
2356
2323
|
}
|
|
2357
2324
|
|
|
@@ -2399,11 +2366,11 @@ if (DEBUG) {
|
|
|
2399
2366
|
Libraries.prototype.logVersions = function () {
|
|
2400
2367
|
let libs = this._registry;
|
|
2401
2368
|
let nameLengths = libs.map(item => get(item, 'name.length'));
|
|
2369
|
+
assert('nameLengths is number array', nameLengths instanceof Array && nameLengths.every(n => typeof n === 'number'));
|
|
2402
2370
|
let maxNameLength = Math.max.apply(null, nameLengths);
|
|
2403
2371
|
debug('-------------------------------');
|
|
2404
2372
|
|
|
2405
|
-
for (let
|
|
2406
|
-
let lib = libs[i];
|
|
2373
|
+
for (let lib of libs) {
|
|
2407
2374
|
let spaces = new Array(maxNameLength - lib.name.length + 1).join(' ');
|
|
2408
2375
|
debug([lib.name, spaces, ' : ', lib.version].join(''));
|
|
2409
2376
|
}
|
|
@@ -2415,39 +2382,6 @@ if (DEBUG) {
|
|
|
2415
2382
|
const LIBRARIES = new Libraries();
|
|
2416
2383
|
LIBRARIES.registerCoreLibrary('Ember', VERSION);
|
|
2417
2384
|
|
|
2418
|
-
/**
|
|
2419
|
-
@module @ember/object
|
|
2420
|
-
*/
|
|
2421
|
-
|
|
2422
|
-
/**
|
|
2423
|
-
To get multiple properties at once, call `getProperties`
|
|
2424
|
-
with an object followed by a list of strings or an array:
|
|
2425
|
-
|
|
2426
|
-
```javascript
|
|
2427
|
-
import { getProperties } from '@ember/object';
|
|
2428
|
-
|
|
2429
|
-
getProperties(record, 'firstName', 'lastName', 'zipCode');
|
|
2430
|
-
// { firstName: 'John', lastName: 'Doe', zipCode: '10011' }
|
|
2431
|
-
```
|
|
2432
|
-
|
|
2433
|
-
is equivalent to:
|
|
2434
|
-
|
|
2435
|
-
```javascript
|
|
2436
|
-
import { getProperties } from '@ember/object';
|
|
2437
|
-
|
|
2438
|
-
getProperties(record, ['firstName', 'lastName', 'zipCode']);
|
|
2439
|
-
// { firstName: 'John', lastName: 'Doe', zipCode: '10011' }
|
|
2440
|
-
```
|
|
2441
|
-
|
|
2442
|
-
@method getProperties
|
|
2443
|
-
@static
|
|
2444
|
-
@for @ember/object
|
|
2445
|
-
@param {Object} obj
|
|
2446
|
-
@param {String...|Array} list of keys to get
|
|
2447
|
-
@return {Object}
|
|
2448
|
-
@public
|
|
2449
|
-
*/
|
|
2450
|
-
|
|
2451
2385
|
function getProperties(obj, keys) {
|
|
2452
2386
|
let ret = {};
|
|
2453
2387
|
let propertyNames = arguments;
|
|
@@ -2501,10 +2435,8 @@ function setProperties(obj, properties) {
|
|
|
2501
2435
|
|
|
2502
2436
|
changeProperties(() => {
|
|
2503
2437
|
let props = Object.keys(properties);
|
|
2504
|
-
let propertyName;
|
|
2505
2438
|
|
|
2506
|
-
for (let
|
|
2507
|
-
propertyName = props[i];
|
|
2439
|
+
for (let propertyName of props) {
|
|
2508
2440
|
set(obj, propertyName, properties[propertyName]);
|
|
2509
2441
|
}
|
|
2510
2442
|
});
|
|
@@ -2551,9 +2483,8 @@ function findNamespaces() {
|
|
|
2551
2483
|
let lookup = context.lookup;
|
|
2552
2484
|
let keys = Object.keys(lookup);
|
|
2553
2485
|
|
|
2554
|
-
for (let
|
|
2555
|
-
|
|
2556
|
-
|
|
2486
|
+
for (let key of keys) {
|
|
2487
|
+
// Only process entities that start with uppercase A-Z
|
|
2557
2488
|
if (!isUppercase(key.charCodeAt(0))) {
|
|
2558
2489
|
continue;
|
|
2559
2490
|
}
|
|
@@ -2586,8 +2517,8 @@ function processAllNamespaces() {
|
|
|
2586
2517
|
if (unprocessedNamespaces || unprocessedMixins) {
|
|
2587
2518
|
let namespaces = NAMESPACES;
|
|
2588
2519
|
|
|
2589
|
-
for (let
|
|
2590
|
-
processNamespace(
|
|
2520
|
+
for (let namespace of namespaces) {
|
|
2521
|
+
processNamespace(namespace);
|
|
2591
2522
|
}
|
|
2592
2523
|
|
|
2593
2524
|
unprocessedMixins = false;
|
|
@@ -2663,10 +2594,7 @@ const {
|
|
|
2663
2594
|
|
|
2664
2595
|
function extractAccessors(properties) {
|
|
2665
2596
|
if (properties !== undefined) {
|
|
2666
|
-
let
|
|
2667
|
-
|
|
2668
|
-
for (let i = 0; i < keys.length; i++) {
|
|
2669
|
-
let key = keys[i];
|
|
2597
|
+
for (let key of Object.keys(properties)) {
|
|
2670
2598
|
let desc = Object.getOwnPropertyDescriptor(properties, key);
|
|
2671
2599
|
|
|
2672
2600
|
if (desc.get !== undefined || desc.set !== undefined) {
|
|
@@ -2748,7 +2676,8 @@ function giveDecoratorSuper(key, decorator, property, descs) {
|
|
|
2748
2676
|
}]);
|
|
2749
2677
|
newProperty._readOnly = property._readOnly;
|
|
2750
2678
|
newProperty._meta = property._meta;
|
|
2751
|
-
newProperty.enumerable = property.enumerable;
|
|
2679
|
+
newProperty.enumerable = property.enumerable; // SAFETY: We passed in the impl for this class
|
|
2680
|
+
|
|
2752
2681
|
return makeComputedDecorator(newProperty, ComputedProperty);
|
|
2753
2682
|
}
|
|
2754
2683
|
|
|
@@ -2799,8 +2728,7 @@ function applyMergedProperties(key, value, values) {
|
|
|
2799
2728
|
let hasFunction = false;
|
|
2800
2729
|
let props = Object.keys(value);
|
|
2801
2730
|
|
|
2802
|
-
for (let
|
|
2803
|
-
let prop = props[i];
|
|
2731
|
+
for (let prop of props) {
|
|
2804
2732
|
let propValue = value[prop];
|
|
2805
2733
|
|
|
2806
2734
|
if (typeof propValue === 'function') {
|
|
@@ -2863,8 +2791,7 @@ function mergeProps(meta$$1, props, descs, values, base, keys, keysWithSuper) {
|
|
|
2863
2791
|
let mergings = concatenatedMixinProperties('mergedProperties', props, values, base);
|
|
2864
2792
|
let propKeys = Object.keys(props);
|
|
2865
2793
|
|
|
2866
|
-
for (let
|
|
2867
|
-
let key = propKeys[i];
|
|
2794
|
+
for (let key of propKeys) {
|
|
2868
2795
|
let value = props[key];
|
|
2869
2796
|
if (value === undefined) continue;
|
|
2870
2797
|
|
|
@@ -2927,16 +2854,16 @@ function updateObserversAndListeners(obj, key, fn, add) {
|
|
|
2927
2854
|
if (observers !== undefined) {
|
|
2928
2855
|
let updateObserver = add ? addObserver : removeObserver;
|
|
2929
2856
|
|
|
2930
|
-
for (let
|
|
2931
|
-
updateObserver(obj,
|
|
2857
|
+
for (let path of observers.paths) {
|
|
2858
|
+
updateObserver(obj, path, null, key, observers.sync);
|
|
2932
2859
|
}
|
|
2933
2860
|
}
|
|
2934
2861
|
|
|
2935
2862
|
if (listeners !== undefined) {
|
|
2936
2863
|
let updateListener = add ? addListener : removeListener;
|
|
2937
2864
|
|
|
2938
|
-
for (let
|
|
2939
|
-
updateListener(obj,
|
|
2865
|
+
for (let listener of listeners) {
|
|
2866
|
+
updateListener(obj, listener, null, key);
|
|
2940
2867
|
}
|
|
2941
2868
|
}
|
|
2942
2869
|
}
|
|
@@ -2957,8 +2884,7 @@ function applyMixin(obj, mixins, _hideKeys = false) {
|
|
|
2957
2884
|
|
|
2958
2885
|
mergeMixins(mixins, meta$$1, descs, values, obj, keys, keysWithSuper);
|
|
2959
2886
|
|
|
2960
|
-
for (let
|
|
2961
|
-
let key = keys[i];
|
|
2887
|
+
for (let key of keys) {
|
|
2962
2888
|
let value = values[key];
|
|
2963
2889
|
let desc = descs[key];
|
|
2964
2890
|
|
|
@@ -3076,6 +3002,7 @@ const MIXINS = new _WeakSet();
|
|
|
3076
3002
|
*/
|
|
3077
3003
|
|
|
3078
3004
|
class Mixin {
|
|
3005
|
+
/** @internal */
|
|
3079
3006
|
constructor(mixins, properties) {
|
|
3080
3007
|
MIXINS.add(this);
|
|
3081
3008
|
this.properties = extractAccessors(properties);
|
|
@@ -3116,6 +3043,8 @@ class Mixin {
|
|
|
3116
3043
|
} // returns the mixins currently applied to the specified object
|
|
3117
3044
|
// TODO: Make `mixin`
|
|
3118
3045
|
|
|
3046
|
+
/** @internal */
|
|
3047
|
+
|
|
3119
3048
|
|
|
3120
3049
|
static mixins(obj) {
|
|
3121
3050
|
let meta$$1 = peekMeta(obj);
|
|
@@ -3137,6 +3066,7 @@ class Mixin {
|
|
|
3137
3066
|
@method reopen
|
|
3138
3067
|
@param arguments*
|
|
3139
3068
|
@private
|
|
3069
|
+
@internal
|
|
3140
3070
|
*/
|
|
3141
3071
|
|
|
3142
3072
|
|
|
@@ -3161,6 +3091,7 @@ class Mixin {
|
|
|
3161
3091
|
@param obj
|
|
3162
3092
|
@return applied object
|
|
3163
3093
|
@private
|
|
3094
|
+
@internal
|
|
3164
3095
|
*/
|
|
3165
3096
|
|
|
3166
3097
|
|
|
@@ -3172,6 +3103,8 @@ class Mixin {
|
|
|
3172
3103
|
// _hideKeys disables enumerablity when applying the mixin. This is a hack, and we should stop mutating the array prototype by default 😫
|
|
3173
3104
|
return applyMixin(obj, [this], _hideKeys);
|
|
3174
3105
|
}
|
|
3106
|
+
/** @internal */
|
|
3107
|
+
|
|
3175
3108
|
|
|
3176
3109
|
applyPartial(obj) {
|
|
3177
3110
|
return applyMixin(obj, [this]);
|
|
@@ -3181,6 +3114,7 @@ class Mixin {
|
|
|
3181
3114
|
@param obj
|
|
3182
3115
|
@return {Boolean}
|
|
3183
3116
|
@private
|
|
3117
|
+
@internal
|
|
3184
3118
|
*/
|
|
3185
3119
|
|
|
3186
3120
|
|
|
@@ -3201,16 +3135,22 @@ class Mixin {
|
|
|
3201
3135
|
|
|
3202
3136
|
return meta$$1.hasMixin(this);
|
|
3203
3137
|
}
|
|
3138
|
+
/** @internal */
|
|
3139
|
+
|
|
3204
3140
|
|
|
3205
3141
|
without(...args) {
|
|
3206
3142
|
let ret = new Mixin([this]);
|
|
3207
3143
|
ret._without = args;
|
|
3208
3144
|
return ret;
|
|
3209
3145
|
}
|
|
3146
|
+
/** @internal */
|
|
3147
|
+
|
|
3210
3148
|
|
|
3211
3149
|
keys() {
|
|
3212
3150
|
return _keys(this);
|
|
3213
3151
|
}
|
|
3152
|
+
/** @internal */
|
|
3153
|
+
|
|
3214
3154
|
|
|
3215
3155
|
toString() {
|
|
3216
3156
|
return '(unknown mixin)';
|
|
@@ -3292,11 +3232,39 @@ function _keys(mixin, ret = new Set(), seen = new Set()) {
|
|
|
3292
3232
|
|
|
3293
3233
|
return ret;
|
|
3294
3234
|
}
|
|
3235
|
+
/**
|
|
3236
|
+
Specify a method that observes property changes.
|
|
3237
|
+
|
|
3238
|
+
```javascript
|
|
3239
|
+
import EmberObject from '@ember/object';
|
|
3240
|
+
import { observer } from '@ember/object';
|
|
3241
|
+
|
|
3242
|
+
export default EmberObject.extend({
|
|
3243
|
+
valueObserver: observer('value', function() {
|
|
3244
|
+
// Executes whenever the "value" property changes
|
|
3245
|
+
})
|
|
3246
|
+
});
|
|
3247
|
+
```
|
|
3248
|
+
|
|
3249
|
+
Also available as `Function.prototype.observes` if prototype extensions are
|
|
3250
|
+
enabled.
|
|
3251
|
+
|
|
3252
|
+
@method observer
|
|
3253
|
+
@for @ember/object
|
|
3254
|
+
@param {String} propertyNames*
|
|
3255
|
+
@param {Function} func
|
|
3256
|
+
@return func
|
|
3257
|
+
@public
|
|
3258
|
+
@static
|
|
3259
|
+
*/
|
|
3260
|
+
|
|
3295
3261
|
|
|
3296
3262
|
function observer(...args) {
|
|
3297
3263
|
let funcOrDef = args.pop();
|
|
3298
3264
|
assert('observer must be provided a function or an observer definition', typeof funcOrDef === 'function' || typeof funcOrDef === 'object' && funcOrDef !== null);
|
|
3299
|
-
let func
|
|
3265
|
+
let func;
|
|
3266
|
+
let dependentKeys;
|
|
3267
|
+
let sync;
|
|
3300
3268
|
|
|
3301
3269
|
if (typeof funcOrDef === 'function') {
|
|
3302
3270
|
func = funcOrDef;
|
|
@@ -3313,8 +3281,8 @@ function observer(...args) {
|
|
|
3313
3281
|
assert('observer called without sync', typeof sync === 'boolean');
|
|
3314
3282
|
let paths = [];
|
|
3315
3283
|
|
|
3316
|
-
for (let
|
|
3317
|
-
expandProperties(
|
|
3284
|
+
for (let dependentKey of dependentKeys) {
|
|
3285
|
+
expandProperties(dependentKey, path => paths.push(path));
|
|
3318
3286
|
}
|
|
3319
3287
|
|
|
3320
3288
|
setObservers(func, {
|
|
@@ -3332,8 +3300,14 @@ if (DEBUG) {
|
|
|
3332
3300
|
|
|
3333
3301
|
function inject(type, ...args) {
|
|
3334
3302
|
assert('a string type must be provided to inject', typeof type === 'string');
|
|
3335
|
-
let
|
|
3336
|
-
let name
|
|
3303
|
+
let elementDescriptor;
|
|
3304
|
+
let name;
|
|
3305
|
+
|
|
3306
|
+
if (isElementDescriptor(args)) {
|
|
3307
|
+
elementDescriptor = args;
|
|
3308
|
+
} else if (typeof args[0] === 'string') {
|
|
3309
|
+
name = args[0];
|
|
3310
|
+
}
|
|
3337
3311
|
|
|
3338
3312
|
let getInjection = function (propertyName) {
|
|
3339
3313
|
let owner = getOwner(this) || this.container; // fallback to `container` for backwards compat
|
|
@@ -3358,8 +3332,8 @@ function inject(type, ...args) {
|
|
|
3358
3332
|
|
|
3359
3333
|
});
|
|
3360
3334
|
|
|
3361
|
-
if (
|
|
3362
|
-
return decorator(
|
|
3335
|
+
if (elementDescriptor) {
|
|
3336
|
+
return decorator(elementDescriptor[0], elementDescriptor[1], elementDescriptor[2]);
|
|
3363
3337
|
} else {
|
|
3364
3338
|
return decorator;
|
|
3365
3339
|
}
|
|
@@ -131,23 +131,28 @@ ControllerMixin.reopen({
|
|
|
131
131
|
aController.transitionToRoute({ queryParams: { sort: 'date' } });
|
|
132
132
|
```
|
|
133
133
|
See also [replaceRoute](/ember/release/classes/Ember.ControllerMixin/methods/replaceRoute?anchor=replaceRoute).
|
|
134
|
-
@
|
|
134
|
+
@for Ember.ControllerMixin
|
|
135
|
+
@method transitionToRoute
|
|
136
|
+
@deprecated Use transitionTo from the Router service instead.
|
|
137
|
+
@param {String} [name] the name of the route or a URL
|
|
135
138
|
@param {...Object} models the model(s) or identifier(s) to be used
|
|
136
139
|
while transitioning to the route.
|
|
137
140
|
@param {Object} [options] optional hash with a queryParams property
|
|
138
141
|
containing a mapping of query parameters
|
|
139
|
-
@for Ember.ControllerMixin
|
|
140
|
-
@method transitionToRoute
|
|
141
142
|
@return {Transition} the transition object associated with this
|
|
142
143
|
attempted transition
|
|
143
|
-
@deprecated Use transitionTo from the Router service instead.
|
|
144
144
|
@public
|
|
145
145
|
*/
|
|
146
146
|
transitionToRoute(...args) {
|
|
147
|
+
var _a;
|
|
148
|
+
|
|
147
149
|
deprecateTransitionMethods('controller', 'transitionToRoute'); // target may be either another controller or a router
|
|
148
150
|
|
|
149
|
-
let target = get(this, 'target');
|
|
150
|
-
|
|
151
|
+
let target = get(this, 'target'); // SAFETY: We can't actually assert that this is a full Controller or Router since some tests
|
|
152
|
+
// mock out an object that only has the single method. Since this is deprecated, I think it's
|
|
153
|
+
// ok to be a little less than proper here.
|
|
154
|
+
|
|
155
|
+
let method = (_a = target.transitionToRoute) !== null && _a !== void 0 ? _a : target.transitionTo;
|
|
151
156
|
return method.apply(target, prefixRouteNameArg(this, args));
|
|
152
157
|
},
|
|
153
158
|
|
|
@@ -190,21 +195,28 @@ ControllerMixin.reopen({
|
|
|
190
195
|
aController.replaceRoute('/');
|
|
191
196
|
aController.replaceRoute('/blog/post/1/comment/13');
|
|
192
197
|
```
|
|
193
|
-
@
|
|
198
|
+
@for Ember.ControllerMixin
|
|
199
|
+
@method replaceRoute
|
|
200
|
+
@deprecated Use replaceWith from the Router service instead.
|
|
201
|
+
@param {String} [name] the name of the route or a URL
|
|
194
202
|
@param {...Object} models the model(s) or identifier(s) to be used
|
|
195
203
|
while transitioning to the route.
|
|
196
|
-
@
|
|
197
|
-
|
|
204
|
+
@param {Object} [options] optional hash with a queryParams property
|
|
205
|
+
containing a mapping of query parameters
|
|
198
206
|
@return {Transition} the transition object associated with this
|
|
199
207
|
attempted transition
|
|
200
|
-
@deprecated Use replaceWith from the Router service instead.
|
|
201
208
|
@public
|
|
202
209
|
*/
|
|
203
210
|
replaceRoute(...args) {
|
|
211
|
+
var _a;
|
|
212
|
+
|
|
204
213
|
deprecateTransitionMethods('controller', 'replaceRoute'); // target may be either another controller or a router
|
|
205
214
|
|
|
206
|
-
let target = get(this, 'target');
|
|
207
|
-
|
|
215
|
+
let target = get(this, 'target'); // SAFETY: We can't actually assert that this is a full Controller or Router since some tests
|
|
216
|
+
// mock out an object that only has the single method. Since this is deprecated, I think it's
|
|
217
|
+
// ok to be a little less than proper here.
|
|
218
|
+
|
|
219
|
+
let method = (_a = target.replaceRoute) !== null && _a !== void 0 ? _a : target.replaceWith;
|
|
208
220
|
return method.apply(target, prefixRouteNameArg(this, args));
|
|
209
221
|
}
|
|
210
222
|
|
|
@@ -82,7 +82,9 @@ export default class AutoLocation extends EmberObject {
|
|
|
82
82
|
implementation = 'none';
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
let
|
|
85
|
+
let owner = getOwner(this);
|
|
86
|
+
assert('AutoLocation is unexpectedly missing an owner', owner);
|
|
87
|
+
let concrete = owner.lookup(`location:${implementation}`);
|
|
86
88
|
assert(`Could not find location '${implementation}'.`, concrete !== undefined);
|
|
87
89
|
set(concrete, 'rootURL', rootURL);
|
|
88
90
|
set(this, 'concreteImplementation', concrete);
|