ember-source 4.2.0-alpha.6 → 4.3.0-alpha.2
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 +4 -0
- 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/ember-template-compiler.js +81 -82
- package/dist/ember-template-compiler.map +1 -1
- package/dist/ember-testing.js +15 -14
- package/dist/ember-testing.map +1 -1
- package/dist/ember.debug.js +498 -476
- 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 +1 -0
- package/dist/packages/@ember/-internals/glimmer/index.js +23 -23
- package/dist/packages/@ember/-internals/meta/lib/meta.js +59 -2
- package/dist/packages/@ember/-internals/metal/index.js +51 -76
- package/dist/packages/@ember/-internals/routing/lib/ext/controller.js +14 -4
- package/dist/packages/@ember/-internals/routing/lib/location/api.js +1 -0
- package/dist/packages/@ember/-internals/routing/lib/services/router.js +2 -47
- package/dist/packages/@ember/-internals/routing/lib/system/route.js +41 -29
- package/dist/packages/@ember/-internals/routing/lib/system/router.js +8 -4
- package/dist/packages/@ember/-internals/routing/lib/utils.js +21 -10
- package/dist/packages/@ember/-internals/utils/index.js +1 -1
- package/dist/packages/@ember/-internals/views/lib/mixins/view_support.js +2 -4
- package/dist/packages/@ember/application/lib/application.js +0 -2
- package/dist/packages/@ember/debug/index.js +1 -1
- package/dist/packages/@ember/debug/lib/deprecate.js +12 -10
- package/dist/packages/@ember/polyfills/lib/assign.js +1 -0
- package/dist/packages/@ember/runloop/index.js +9 -9
- 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 +2367 -1650
- package/package.json +21 -21
- 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
package/dist/header/license.js
CHANGED
package/dist/header/loader.js
CHANGED
|
@@ -2,9 +2,7 @@ import require from 'require';
|
|
|
2
2
|
|
|
3
3
|
(function bootstrap() {
|
|
4
4
|
// Bootstrap Node module
|
|
5
|
-
// eslint-disable-next-line no-undef
|
|
6
5
|
if (typeof module === 'object' && typeof module.require === 'function') {
|
|
7
|
-
// tslint:disable-next-line: no-require-imports
|
|
8
6
|
module.exports = require('ember').default;
|
|
9
7
|
}
|
|
10
8
|
})();
|
|
@@ -2,11 +2,11 @@ import { templateFactory, programCompilationContext } from '@glimmer/opcode-comp
|
|
|
2
2
|
export { templateFactory as template, templateCacheCounters } from '@glimmer/opcode-compiler';
|
|
3
3
|
import { setOwner, getOwner } from '@ember/-internals/owner';
|
|
4
4
|
import { guidFor, symbol, enumerableSymbol, getDebugName, isProxy, isEmberArray, isObject, uuid } from '@ember/-internals/utils';
|
|
5
|
-
import { assert, warn, debugFreeze, deprecate } from '@ember/debug';
|
|
5
|
+
import { assert, warn, debugFreeze, inspect, deprecate } from '@ember/debug';
|
|
6
6
|
import { setComponentTemplate, setInternalComponentManager, setInternalHelperManager, getInternalHelperManager, helperCapabilities, setHelperManager, capabilityFlagsFrom, setInternalModifierManager, getComponentTemplate, getInternalComponentManager, componentCapabilities, modifierCapabilities, setComponentManager } from '@glimmer/manager';
|
|
7
7
|
import { createConstRef, isConstRef, valueForRef, isUpdatableRef, updateRef, childRefFor, childRefFromParts, createComputeRef, createPrimitiveRef, createUnboundRef, isInvokableRef, createInvokableRef, createReadOnlyRef, createDebugAliasRef, UNDEFINED_REFERENCE } from '@glimmer/reference';
|
|
8
8
|
import { untrack, consumeTag, createCache, getValue, tagFor, beginUntrackFrame, endUntrackFrame, valueForTag, beginTrackFrame, endTrackFrame, validateTag, createTag, dirtyTag, CONSTANT_TAG, isTracking, setTrackingTransactionEnv, createUpdatableTag, CURRENT_TAG } from '@glimmer/validator';
|
|
9
|
-
import { tracked, get, PROPERTY_DID_CHANGE, tagForObject, objectAt, tagForProperty, _getProp, _setProp
|
|
9
|
+
import { tracked, get, PROPERTY_DID_CHANGE, tagForObject, objectAt, tagForProperty, set, _getProp, _setProp } from '@ember/-internals/metal';
|
|
10
10
|
import { action } from '@ember/object';
|
|
11
11
|
import { hasDOM } from '@ember/-internals/browser-environment';
|
|
12
12
|
import { isSimpleClick, clearElementView, clearViewElement, getViewElement, MUTABLE_CELL, addChildView, setElementView, setViewElement, ActionSupport, ChildViewsSupport, ClassNamesSupport, CoreView, ViewMixin, ViewStateSupport, constructStyleDeprecationMessage, ActionManager, getViewId } from '@ember/-internals/views';
|
|
@@ -16,9 +16,9 @@ import { service } from '@ember/service';
|
|
|
16
16
|
import { DEBUG } from '@glimmer/env';
|
|
17
17
|
import { dasherize } from '@ember/string';
|
|
18
18
|
import { registerDestructor, associateDestroyableChild, destroy } from '@glimmer/destroyable';
|
|
19
|
-
import { join,
|
|
19
|
+
import { join, schedule, _backburner, _getCurrentRunLoop } from '@ember/runloop';
|
|
20
20
|
import { _WeakSet, EMPTY_ARRAY, unwrapTemplate, dict } from '@glimmer/util';
|
|
21
|
-
import { reifyPositional, normalizeProperty, EMPTY_ARGS, createCapturedArgs, curry, EMPTY_POSITIONAL, array, concat, fn, get as get$1, hash, on,
|
|
21
|
+
import { reifyPositional, normalizeProperty, EMPTY_ARGS, createCapturedArgs, curry, EMPTY_POSITIONAL, array, concat, fn, get as get$1, hash, on, templateOnlyComponent, TEMPLATE_ONLY_COMPONENT_MANAGER, clientBuilder, DOMChanges, DOMTreeConstruction, inTransaction, renderMain, runtimeContext, rehydrationBuilder } from '@glimmer/runtime';
|
|
22
22
|
export { DOMChanges, DOMTreeConstruction, isSerializationFirstNode } from '@glimmer/runtime';
|
|
23
23
|
import { TargetActionSupport, FrameworkObject, _contentFor, isArray } from '@ember/-internals/runtime';
|
|
24
24
|
import { ENV } from '@ember/-internals/environment';
|
|
@@ -975,9 +975,15 @@ class LinkTo extends InternalComponent {
|
|
|
975
975
|
try {
|
|
976
976
|
return routing.generateURL(route, models, query);
|
|
977
977
|
} catch (e) {
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
978
|
+
let details = e instanceof Error ? e.message : inspect(e);
|
|
979
|
+
let message = `While generating link to route "${route}": ${details}`;
|
|
980
|
+
|
|
981
|
+
if (e instanceof Error) {
|
|
982
|
+
e.message = message;
|
|
983
|
+
throw e;
|
|
984
|
+
} else {
|
|
985
|
+
throw message;
|
|
986
|
+
}
|
|
981
987
|
}
|
|
982
988
|
} else {
|
|
983
989
|
return routing.generateURL(route, models, query);
|
|
@@ -1023,8 +1029,7 @@ class LinkTo extends InternalComponent {
|
|
|
1023
1029
|
transition: undefined
|
|
1024
1030
|
};
|
|
1025
1031
|
flaggedInstrument('interaction.link-to', payload, () => {
|
|
1026
|
-
assert('[BUG] route can only be missing if isLoading is true', isPresent(route));
|
|
1027
|
-
|
|
1032
|
+
assert('[BUG] route can only be missing if isLoading is true', isPresent(route));
|
|
1028
1033
|
payload.transition = routing.transitionTo(route, models, query, replace);
|
|
1029
1034
|
});
|
|
1030
1035
|
}
|
|
@@ -1054,8 +1059,7 @@ class LinkTo extends InternalComponent {
|
|
|
1054
1059
|
} else {
|
|
1055
1060
|
return EMPTY_ARRAY$1;
|
|
1056
1061
|
}
|
|
1057
|
-
}
|
|
1058
|
-
|
|
1062
|
+
}
|
|
1059
1063
|
|
|
1060
1064
|
get query() {
|
|
1061
1065
|
if ('query' in this.args.named) {
|
|
@@ -1155,8 +1159,7 @@ class LinkTo extends InternalComponent {
|
|
|
1155
1159
|
query,
|
|
1156
1160
|
routing
|
|
1157
1161
|
} = this;
|
|
1158
|
-
assert('[BUG] route can only be missing if isLoading is true', isPresent(route));
|
|
1159
|
-
|
|
1162
|
+
assert('[BUG] route can only be missing if isLoading is true', isPresent(route));
|
|
1160
1163
|
return routing.isActiveForRoute(models, query, route, state);
|
|
1161
1164
|
}
|
|
1162
1165
|
}
|
|
@@ -1491,8 +1494,8 @@ function installAttributeBinding(component, rootRef, parsed, operations) {
|
|
|
1491
1494
|
elementId = component.elementId;
|
|
1492
1495
|
}
|
|
1493
1496
|
|
|
1494
|
-
|
|
1495
|
-
operations.setAttribute('id',
|
|
1497
|
+
let elementIdRef = createPrimitiveRef(elementId);
|
|
1498
|
+
operations.setAttribute('id', elementIdRef, true, null);
|
|
1496
1499
|
return;
|
|
1497
1500
|
}
|
|
1498
1501
|
|
|
@@ -1962,7 +1965,6 @@ function makeClosureAction(context, target, action$$1, processArgs, debugKey) {
|
|
|
1962
1965
|
self = context;
|
|
1963
1966
|
fn$$1 = action$$1;
|
|
1964
1967
|
} else {
|
|
1965
|
-
// tslint:disable-next-line:max-line-length
|
|
1966
1968
|
assert(`An action could not be made for \`${debugKey || action$$1}\` in ${target}. Please confirm that you are using either a quoted action name (i.e. \`(action '${debugKey || 'myAction'}')\`) or a function available in ${target}.`, false);
|
|
1967
1969
|
}
|
|
1968
1970
|
|
|
@@ -2048,7 +2050,6 @@ const EMBER_VIEW_REF = createPrimitiveRef('ember-view');
|
|
|
2048
2050
|
|
|
2049
2051
|
function aliasIdToElementId(args, props) {
|
|
2050
2052
|
if (args.named.has('id')) {
|
|
2051
|
-
// tslint:disable-next-line:max-line-length
|
|
2052
2053
|
assert(`You cannot invoke a component with both 'id' and 'elementId' at the same time.`, !args.named.has('elementId'));
|
|
2053
2054
|
props.elementId = props.id;
|
|
2054
2055
|
}
|
|
@@ -3141,7 +3142,7 @@ const Component = CoreView.extend(ChildViewsSupport, ViewStateSupport, ClassName
|
|
|
3141
3142
|
|
|
3142
3143
|
if (DEBUG && eventDispatcher && this.renderer._isInteractive && this.tagName === '') {
|
|
3143
3144
|
let eventNames = [];
|
|
3144
|
-
let events = eventDispatcher.finalEventNameMapping;
|
|
3145
|
+
let events = eventDispatcher.finalEventNameMapping;
|
|
3145
3146
|
|
|
3146
3147
|
for (let key in events) {
|
|
3147
3148
|
let methodName = events[key];
|
|
@@ -3152,8 +3153,7 @@ const Component = CoreView.extend(ChildViewsSupport, ViewStateSupport, ClassName
|
|
|
3152
3153
|
} // If in a tagless component, assert that no event handlers are defined
|
|
3153
3154
|
|
|
3154
3155
|
|
|
3155
|
-
assert(
|
|
3156
|
-
`You can not define \`${eventNames}\` function(s) to handle DOM event in the \`${this}\` tagless component since it doesn't have any DOM element.`, !eventNames.length);
|
|
3156
|
+
assert(`You can not define \`${eventNames}\` function(s) to handle DOM event in the \`${this}\` tagless component since it doesn't have any DOM element.`, !eventNames.length);
|
|
3157
3157
|
}
|
|
3158
3158
|
},
|
|
3159
3159
|
|
|
@@ -3546,7 +3546,7 @@ class ClassicHelperManager {
|
|
|
3546
3546
|
}
|
|
3547
3547
|
|
|
3548
3548
|
getDebugName(definition) {
|
|
3549
|
-
return getDebugName(definition.class['prototype']);
|
|
3549
|
+
return getDebugName((definition.class || definition)['prototype']);
|
|
3550
3550
|
}
|
|
3551
3551
|
|
|
3552
3552
|
}
|
|
@@ -4516,6 +4516,7 @@ const VM_DEPRECATION_OVERRIDES = [{
|
|
|
4516
4516
|
until: '4.4.0',
|
|
4517
4517
|
for: 'ember-source',
|
|
4518
4518
|
since: {
|
|
4519
|
+
available: '3.28.0',
|
|
4519
4520
|
enabled: '3.28.0'
|
|
4520
4521
|
}
|
|
4521
4522
|
}];
|
|
@@ -5744,13 +5745,11 @@ class DynamicScope {
|
|
|
5744
5745
|
}
|
|
5745
5746
|
|
|
5746
5747
|
get(key) {
|
|
5747
|
-
// tslint:disable-next-line:max-line-length
|
|
5748
5748
|
assert(`Using \`-get-dynamic-scope\` is only supported for \`outletState\` (you used \`${key}\`).`, key === 'outletState');
|
|
5749
5749
|
return this.outletState;
|
|
5750
5750
|
}
|
|
5751
5751
|
|
|
5752
5752
|
set(key, value) {
|
|
5753
|
-
// tslint:disable-next-line:max-line-length
|
|
5754
5753
|
assert(`Using \`-with-dynamic-scope\` is only supported for \`outletState\` (you used \`${key}\`).`, key === 'outletState');
|
|
5755
5754
|
this.outletState = value;
|
|
5756
5755
|
return value;
|
|
@@ -5773,6 +5772,7 @@ function errorLoopTransaction(fn$$1) {
|
|
|
5773
5772
|
// Noop the function so that we won't keep calling it and causing
|
|
5774
5773
|
// infinite looping failures;
|
|
5775
5774
|
fn$$1 = () => {
|
|
5775
|
+
// eslint-disable-next-line no-console
|
|
5776
5776
|
console.warn('Attempted to rerender, but the Ember application has had an unrecoverable error occur during render. You should reload the application after fixing the cause of the error.');
|
|
5777
5777
|
};
|
|
5778
5778
|
}
|
|
@@ -36,9 +36,16 @@ export const UNDEFINED = symbol('undefined');
|
|
|
36
36
|
let currentListenerVersion = 1;
|
|
37
37
|
export class Meta {
|
|
38
38
|
// DEBUG
|
|
39
|
+
|
|
40
|
+
/** @internal */
|
|
39
41
|
constructor(obj) {
|
|
42
|
+
/** @internal */
|
|
40
43
|
this._listenersVersion = 1;
|
|
44
|
+
/** @internal */
|
|
45
|
+
|
|
41
46
|
this._inheritedEnd = -1;
|
|
47
|
+
/** @internal */
|
|
48
|
+
|
|
42
49
|
this._flattenedVersion = 0;
|
|
43
50
|
|
|
44
51
|
if (DEBUG) {
|
|
@@ -59,6 +66,8 @@ export class Meta {
|
|
|
59
66
|
this.proto = obj.constructor === undefined ? undefined : obj.constructor.prototype;
|
|
60
67
|
this._listeners = undefined;
|
|
61
68
|
}
|
|
69
|
+
/** @internal */
|
|
70
|
+
|
|
62
71
|
|
|
63
72
|
get parent() {
|
|
64
73
|
let parent = this._parent;
|
|
@@ -74,26 +83,38 @@ export class Meta {
|
|
|
74
83
|
setInitializing() {
|
|
75
84
|
this._isInit = true;
|
|
76
85
|
}
|
|
86
|
+
/** @internal */
|
|
87
|
+
|
|
77
88
|
|
|
78
89
|
unsetInitializing() {
|
|
79
90
|
this._isInit = false;
|
|
80
91
|
}
|
|
92
|
+
/** @internal */
|
|
93
|
+
|
|
81
94
|
|
|
82
95
|
isInitializing() {
|
|
83
96
|
return this._isInit;
|
|
84
97
|
}
|
|
98
|
+
/** @internal */
|
|
99
|
+
|
|
85
100
|
|
|
86
101
|
isPrototypeMeta(obj) {
|
|
87
102
|
return this.proto === this.source && this.source === obj;
|
|
88
103
|
}
|
|
104
|
+
/** @internal */
|
|
105
|
+
|
|
89
106
|
|
|
90
107
|
_getOrCreateOwnMap(key) {
|
|
91
108
|
return this[key] || (this[key] = Object.create(null));
|
|
92
109
|
}
|
|
110
|
+
/** @internal */
|
|
111
|
+
|
|
93
112
|
|
|
94
113
|
_getOrCreateOwnSet(key) {
|
|
95
114
|
return this[key] || (this[key] = new Set());
|
|
96
115
|
}
|
|
116
|
+
/** @internal */
|
|
117
|
+
|
|
97
118
|
|
|
98
119
|
_findInheritedMap(key, subkey) {
|
|
99
120
|
let pointer = this;
|
|
@@ -112,6 +133,8 @@ export class Meta {
|
|
|
112
133
|
pointer = pointer.parent;
|
|
113
134
|
}
|
|
114
135
|
}
|
|
136
|
+
/** @internal */
|
|
137
|
+
|
|
115
138
|
|
|
116
139
|
_hasInInheritedSet(key, value) {
|
|
117
140
|
let pointer = this;
|
|
@@ -128,28 +151,38 @@ export class Meta {
|
|
|
128
151
|
|
|
129
152
|
return false;
|
|
130
153
|
}
|
|
154
|
+
/** @internal */
|
|
155
|
+
|
|
131
156
|
|
|
132
157
|
valueFor(key) {
|
|
133
158
|
let values = this._values;
|
|
134
159
|
return values !== undefined ? values[key] : undefined;
|
|
135
160
|
}
|
|
161
|
+
/** @internal */
|
|
162
|
+
|
|
136
163
|
|
|
137
164
|
setValueFor(key, value) {
|
|
138
165
|
let values = this._getOrCreateOwnMap('_values');
|
|
139
166
|
|
|
140
167
|
values[key] = value;
|
|
141
168
|
}
|
|
169
|
+
/** @internal */
|
|
170
|
+
|
|
142
171
|
|
|
143
172
|
revisionFor(key) {
|
|
144
173
|
let revisions = this._revisions;
|
|
145
174
|
return revisions !== undefined ? revisions[key] : undefined;
|
|
146
175
|
}
|
|
176
|
+
/** @internal */
|
|
177
|
+
|
|
147
178
|
|
|
148
179
|
setRevisionFor(key, revision) {
|
|
149
180
|
let revisions = this._getOrCreateOwnMap('_revisions');
|
|
150
181
|
|
|
151
182
|
revisions[key] = revision;
|
|
152
183
|
}
|
|
184
|
+
/** @internal */
|
|
185
|
+
|
|
153
186
|
|
|
154
187
|
writableLazyChainsFor(key) {
|
|
155
188
|
if (DEBUG) {
|
|
@@ -166,6 +199,8 @@ export class Meta {
|
|
|
166
199
|
|
|
167
200
|
return chains;
|
|
168
201
|
}
|
|
202
|
+
/** @internal */
|
|
203
|
+
|
|
169
204
|
|
|
170
205
|
readableLazyChainsFor(key) {
|
|
171
206
|
if (DEBUG) {
|
|
@@ -180,6 +215,8 @@ export class Meta {
|
|
|
180
215
|
|
|
181
216
|
return undefined;
|
|
182
217
|
}
|
|
218
|
+
/** @internal */
|
|
219
|
+
|
|
183
220
|
|
|
184
221
|
addMixin(mixin) {
|
|
185
222
|
assert(isDestroyed(this.source) ? `Cannot add mixins of \`${toString(mixin)}\` on \`${toString(this.source)}\` call addMixin after it has been destroyed.` : '', !isDestroyed(this.source));
|
|
@@ -188,10 +225,14 @@ export class Meta {
|
|
|
188
225
|
|
|
189
226
|
set.add(mixin);
|
|
190
227
|
}
|
|
228
|
+
/** @internal */
|
|
229
|
+
|
|
191
230
|
|
|
192
231
|
hasMixin(mixin) {
|
|
193
232
|
return this._hasInInheritedSet('_mixins', mixin);
|
|
194
233
|
}
|
|
234
|
+
/** @internal */
|
|
235
|
+
|
|
195
236
|
|
|
196
237
|
forEachMixins(fn) {
|
|
197
238
|
let pointer = this;
|
|
@@ -214,22 +255,30 @@ export class Meta {
|
|
|
214
255
|
pointer = pointer.parent;
|
|
215
256
|
}
|
|
216
257
|
}
|
|
258
|
+
/** @internal */
|
|
259
|
+
|
|
217
260
|
|
|
218
261
|
writeDescriptors(subkey, value) {
|
|
219
262
|
assert(isDestroyed(this.source) ? `Cannot update descriptors for \`${subkey}\` on \`${toString(this.source)}\` after it has been destroyed.` : '', !isDestroyed(this.source));
|
|
220
263
|
let map = this._descriptors || (this._descriptors = new Map());
|
|
221
264
|
map.set(subkey, value);
|
|
222
265
|
}
|
|
266
|
+
/** @internal */
|
|
267
|
+
|
|
223
268
|
|
|
224
269
|
peekDescriptors(subkey) {
|
|
225
270
|
let possibleDesc = this._findInheritedMap('_descriptors', subkey);
|
|
226
271
|
|
|
227
272
|
return possibleDesc === UNDEFINED ? undefined : possibleDesc;
|
|
228
273
|
}
|
|
274
|
+
/** @internal */
|
|
275
|
+
|
|
229
276
|
|
|
230
277
|
removeDescriptors(subkey) {
|
|
231
278
|
this.writeDescriptors(subkey, UNDEFINED);
|
|
232
279
|
}
|
|
280
|
+
/** @internal */
|
|
281
|
+
|
|
233
282
|
|
|
234
283
|
forEachDescriptors(fn) {
|
|
235
284
|
let pointer = this;
|
|
@@ -254,6 +303,8 @@ export class Meta {
|
|
|
254
303
|
pointer = pointer.parent;
|
|
255
304
|
}
|
|
256
305
|
}
|
|
306
|
+
/** @internal */
|
|
307
|
+
|
|
257
308
|
|
|
258
309
|
addToListeners(eventName, target, method, once, sync) {
|
|
259
310
|
if (DEBUG) {
|
|
@@ -266,6 +317,8 @@ export class Meta {
|
|
|
266
317
|
/* ADD */
|
|
267
318
|
, sync);
|
|
268
319
|
}
|
|
320
|
+
/** @internal */
|
|
321
|
+
|
|
269
322
|
|
|
270
323
|
removeFromListeners(eventName, target, method) {
|
|
271
324
|
if (DEBUG) {
|
|
@@ -311,8 +364,8 @@ export class Meta {
|
|
|
311
364
|
&& listener.kind !== 2
|
|
312
365
|
/* REMOVE */
|
|
313
366
|
) {
|
|
314
|
-
|
|
315
|
-
|
|
367
|
+
listeners.splice(i, 1);
|
|
368
|
+
} else {
|
|
316
369
|
assert(`You attempted to add an observer for the same method on '${event.split(':')[0]}' twice to ${target} as both sync and async. Observers must be either sync or async, they cannot be both. This is likely a mistake, you should either remove the code that added the observer a second time, or update it to always be sync or async. The method was ${method}.`, !(listener.kind === 0
|
|
317
370
|
/* ADD */
|
|
318
371
|
&& kind === 0
|
|
@@ -416,6 +469,8 @@ export class Meta {
|
|
|
416
469
|
|
|
417
470
|
return this._listeners;
|
|
418
471
|
}
|
|
472
|
+
/** @internal */
|
|
473
|
+
|
|
419
474
|
|
|
420
475
|
matchingListeners(eventName) {
|
|
421
476
|
let listeners = this.flattenedListeners();
|
|
@@ -450,6 +505,8 @@ export class Meta {
|
|
|
450
505
|
|
|
451
506
|
return result;
|
|
452
507
|
}
|
|
508
|
+
/** @internal */
|
|
509
|
+
|
|
453
510
|
|
|
454
511
|
observerEvents() {
|
|
455
512
|
let listeners = this.flattenedListeners();
|
|
@@ -759,7 +759,6 @@ function getChainTags(chainTags, obj, path, tagMeta, meta$$1) {
|
|
|
759
759
|
descriptor = currentMeta !== null ? currentMeta.peekDescriptors(segment) : undefined; // If the key is an alias, we need to bootstrap it
|
|
760
760
|
|
|
761
761
|
if (descriptor !== undefined && typeof descriptor.altKey === 'string') {
|
|
762
|
-
// tslint:disable-next-line: no-unused-expression
|
|
763
762
|
item[segment];
|
|
764
763
|
}
|
|
765
764
|
}
|
|
@@ -781,7 +780,6 @@ function getChainTags(chainTags, obj, path, tagMeta, meta$$1) {
|
|
|
781
780
|
// bootstrap the alias. This is because aliases, unlike other CPs, should
|
|
782
781
|
// always be in sync with the aliased value.
|
|
783
782
|
if (CHAIN_PASS_THROUGH.has(descriptor)) {
|
|
784
|
-
// tslint:disable-next-line: no-unused-expression
|
|
785
783
|
current[segment];
|
|
786
784
|
}
|
|
787
785
|
|
|
@@ -1585,11 +1583,15 @@ class ComputedDecoratorImpl extends Function {
|
|
|
1585
1583
|
} // TODO: Remove this when we can provide alternatives in the ecosystem to
|
|
1586
1584
|
// addons such as ember-macro-helpers that use it.
|
|
1587
1585
|
|
|
1586
|
+
/** @internal */
|
|
1587
|
+
|
|
1588
1588
|
|
|
1589
1589
|
get _getter() {
|
|
1590
1590
|
return descriptorForDecorator(this)._getter;
|
|
1591
1591
|
} // TODO: Refactor this, this is an internal API only
|
|
1592
1592
|
|
|
1593
|
+
/** @internal */
|
|
1594
|
+
|
|
1593
1595
|
|
|
1594
1596
|
set enumerable(value) {
|
|
1595
1597
|
descriptorForDecorator(this).enumerable = value;
|
|
@@ -1633,6 +1635,8 @@ function getCachedValueFor(obj, key) {
|
|
|
1633
1635
|
|
|
1634
1636
|
if (meta$$1) {
|
|
1635
1637
|
return meta$$1.valueFor(key);
|
|
1638
|
+
} else {
|
|
1639
|
+
return undefined;
|
|
1636
1640
|
}
|
|
1637
1641
|
}
|
|
1638
1642
|
|
|
@@ -1766,45 +1770,7 @@ if (DEBUG) {
|
|
|
1766
1770
|
return Reflect.get(content, keyName, obj);
|
|
1767
1771
|
}
|
|
1768
1772
|
};
|
|
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
|
-
|
|
1773
|
+
}
|
|
1808
1774
|
|
|
1809
1775
|
function get(obj, keyName) {
|
|
1810
1776
|
assert(`Get must be called with two arguments; an object and a property key`, arguments.length === 2);
|
|
@@ -2083,7 +2049,6 @@ class AliasedProperty extends ComputedDescriptor {
|
|
|
2083
2049
|
}
|
|
2084
2050
|
|
|
2085
2051
|
function AliasedProperty_readOnlySet(obj, keyName) {
|
|
2086
|
-
// eslint-disable-line no-unused-vars
|
|
2087
2052
|
throw new EmberError(`Cannot set read-only property '${keyName}' on object: ${inspect(obj)}`);
|
|
2088
2053
|
}
|
|
2089
2054
|
|
|
@@ -2399,6 +2364,7 @@ if (DEBUG) {
|
|
|
2399
2364
|
Libraries.prototype.logVersions = function () {
|
|
2400
2365
|
let libs = this._registry;
|
|
2401
2366
|
let nameLengths = libs.map(item => get(item, 'name.length'));
|
|
2367
|
+
assert('nameLengths is number array', nameLengths instanceof Array && nameLengths.every(n => typeof n === 'number'));
|
|
2402
2368
|
let maxNameLength = Math.max.apply(null, nameLengths);
|
|
2403
2369
|
debug('-------------------------------');
|
|
2404
2370
|
|
|
@@ -2415,39 +2381,6 @@ if (DEBUG) {
|
|
|
2415
2381
|
const LIBRARIES = new Libraries();
|
|
2416
2382
|
LIBRARIES.registerCoreLibrary('Ember', VERSION);
|
|
2417
2383
|
|
|
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
2384
|
function getProperties(obj, keys) {
|
|
2452
2385
|
let ret = {};
|
|
2453
2386
|
let propertyNames = arguments;
|
|
@@ -3076,6 +3009,7 @@ const MIXINS = new _WeakSet();
|
|
|
3076
3009
|
*/
|
|
3077
3010
|
|
|
3078
3011
|
class Mixin {
|
|
3012
|
+
/** @internal */
|
|
3079
3013
|
constructor(mixins, properties) {
|
|
3080
3014
|
MIXINS.add(this);
|
|
3081
3015
|
this.properties = extractAccessors(properties);
|
|
@@ -3116,6 +3050,8 @@ class Mixin {
|
|
|
3116
3050
|
} // returns the mixins currently applied to the specified object
|
|
3117
3051
|
// TODO: Make `mixin`
|
|
3118
3052
|
|
|
3053
|
+
/** @internal */
|
|
3054
|
+
|
|
3119
3055
|
|
|
3120
3056
|
static mixins(obj) {
|
|
3121
3057
|
let meta$$1 = peekMeta(obj);
|
|
@@ -3137,6 +3073,7 @@ class Mixin {
|
|
|
3137
3073
|
@method reopen
|
|
3138
3074
|
@param arguments*
|
|
3139
3075
|
@private
|
|
3076
|
+
@internal
|
|
3140
3077
|
*/
|
|
3141
3078
|
|
|
3142
3079
|
|
|
@@ -3161,6 +3098,7 @@ class Mixin {
|
|
|
3161
3098
|
@param obj
|
|
3162
3099
|
@return applied object
|
|
3163
3100
|
@private
|
|
3101
|
+
@internal
|
|
3164
3102
|
*/
|
|
3165
3103
|
|
|
3166
3104
|
|
|
@@ -3172,6 +3110,8 @@ class Mixin {
|
|
|
3172
3110
|
// _hideKeys disables enumerablity when applying the mixin. This is a hack, and we should stop mutating the array prototype by default 😫
|
|
3173
3111
|
return applyMixin(obj, [this], _hideKeys);
|
|
3174
3112
|
}
|
|
3113
|
+
/** @internal */
|
|
3114
|
+
|
|
3175
3115
|
|
|
3176
3116
|
applyPartial(obj) {
|
|
3177
3117
|
return applyMixin(obj, [this]);
|
|
@@ -3181,6 +3121,7 @@ class Mixin {
|
|
|
3181
3121
|
@param obj
|
|
3182
3122
|
@return {Boolean}
|
|
3183
3123
|
@private
|
|
3124
|
+
@internal
|
|
3184
3125
|
*/
|
|
3185
3126
|
|
|
3186
3127
|
|
|
@@ -3201,16 +3142,22 @@ class Mixin {
|
|
|
3201
3142
|
|
|
3202
3143
|
return meta$$1.hasMixin(this);
|
|
3203
3144
|
}
|
|
3145
|
+
/** @internal */
|
|
3146
|
+
|
|
3204
3147
|
|
|
3205
3148
|
without(...args) {
|
|
3206
3149
|
let ret = new Mixin([this]);
|
|
3207
3150
|
ret._without = args;
|
|
3208
3151
|
return ret;
|
|
3209
3152
|
}
|
|
3153
|
+
/** @internal */
|
|
3154
|
+
|
|
3210
3155
|
|
|
3211
3156
|
keys() {
|
|
3212
3157
|
return _keys(this);
|
|
3213
3158
|
}
|
|
3159
|
+
/** @internal */
|
|
3160
|
+
|
|
3214
3161
|
|
|
3215
3162
|
toString() {
|
|
3216
3163
|
return '(unknown mixin)';
|
|
@@ -3292,11 +3239,39 @@ function _keys(mixin, ret = new Set(), seen = new Set()) {
|
|
|
3292
3239
|
|
|
3293
3240
|
return ret;
|
|
3294
3241
|
}
|
|
3242
|
+
/**
|
|
3243
|
+
Specify a method that observes property changes.
|
|
3244
|
+
|
|
3245
|
+
```javascript
|
|
3246
|
+
import EmberObject from '@ember/object';
|
|
3247
|
+
import { observer } from '@ember/object';
|
|
3248
|
+
|
|
3249
|
+
export default EmberObject.extend({
|
|
3250
|
+
valueObserver: observer('value', function() {
|
|
3251
|
+
// Executes whenever the "value" property changes
|
|
3252
|
+
})
|
|
3253
|
+
});
|
|
3254
|
+
```
|
|
3255
|
+
|
|
3256
|
+
Also available as `Function.prototype.observes` if prototype extensions are
|
|
3257
|
+
enabled.
|
|
3258
|
+
|
|
3259
|
+
@method observer
|
|
3260
|
+
@for @ember/object
|
|
3261
|
+
@param {String} propertyNames*
|
|
3262
|
+
@param {Function} func
|
|
3263
|
+
@return func
|
|
3264
|
+
@public
|
|
3265
|
+
@static
|
|
3266
|
+
*/
|
|
3267
|
+
|
|
3295
3268
|
|
|
3296
3269
|
function observer(...args) {
|
|
3297
3270
|
let funcOrDef = args.pop();
|
|
3298
3271
|
assert('observer must be provided a function or an observer definition', typeof funcOrDef === 'function' || typeof funcOrDef === 'object' && funcOrDef !== null);
|
|
3299
|
-
let func
|
|
3272
|
+
let func;
|
|
3273
|
+
let dependentKeys;
|
|
3274
|
+
let sync;
|
|
3300
3275
|
|
|
3301
3276
|
if (typeof funcOrDef === 'function') {
|
|
3302
3277
|
func = funcOrDef;
|