ember-source 4.3.0-alpha.3 → 4.4.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 +6 -2
- package/blueprints/acceptance-test/mocha-files/tests/acceptance/__name__-test.js +4 -4
- package/blueprints/acceptance-test/mocha-rfc-232-files/tests/acceptance/__name__-test.js +2 -2
- package/blueprints/acceptance-test/qunit-files/tests/acceptance/__name__-test.js +2 -2
- package/blueprints/acceptance-test/qunit-rfc-232-files/tests/acceptance/__name__-test.js +2 -2
- package/blueprints/component/index.js +2 -2
- package/blueprints/component-class/index.js +2 -2
- package/blueprints/component-test/mocha-0.12-files/__root__/__testType__/__path__/__test__.js +4 -4
- package/blueprints/component-test/mocha-files/__root__/__testType__/__path__/__test__.js +7 -5
- package/blueprints/component-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js +4 -4
- package/blueprints/component-test/qunit-files/__root__/__testType__/__path__/__test__.js +4 -4
- package/blueprints/component-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js +4 -4
- package/blueprints/controller/files/__root__/__path__/__name__.js +1 -2
- package/blueprints/controller-test/mocha-0.12-files/__root__/__testType__/__path__/__test__.js +2 -2
- package/blueprints/controller-test/mocha-files/__root__/__testType__/__path__/__test__.js +5 -3
- package/blueprints/controller-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js +2 -2
- package/blueprints/controller-test/qunit-files/__root__/__testType__/__path__/__test__.js +1 -1
- package/blueprints/controller-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js +2 -2
- package/blueprints/helper/files/__root__/__collection__/__name__.js +1 -1
- package/blueprints/helper/mu-files/__root__/__collection__/__name__.js +1 -1
- package/blueprints/helper-test/mocha-0.12-files/__root__/__testType__/__collection__/__name__-test.js +3 -3
- package/blueprints/helper-test/mocha-files/__root__/__testType__/__collection__/__name__-test.js +6 -4
- package/blueprints/helper-test/mocha-rfc-232-files/__root__/__testType__/__collection__/__name__-test.js +2 -2
- package/blueprints/helper-test/qunit-files/__root__/__testType__/__collection__/__name__-test.js +2 -2
- package/blueprints/helper-test/qunit-rfc-232-files/__root__/__testType__/__collection__/__name__-test.js +2 -2
- package/blueprints/initializer/files/__root__/initializers/__name__.js +2 -3
- package/blueprints/initializer-test/mocha-files/__root__/__testType__/__path__/__name__-test.js +6 -7
- package/blueprints/initializer-test/mocha-rfc-232-files/__root__/__testType__/__path__/__name__-test.js +5 -5
- package/blueprints/initializer-test/qunit-files/__root__/__testType__/__path__/__name__-test.js +3 -4
- package/blueprints/instance-initializer/files/__root__/instance-initializers/__name__.js +2 -3
- package/blueprints/instance-initializer-test/mocha-files/__root__/__testType__/__path__/__name__-test.js +5 -5
- package/blueprints/instance-initializer-test/mocha-rfc-232-files/__root__/__testType__/__path__/__name__-test.js +5 -5
- package/blueprints/instance-initializer-test/qunit-files/__root__/__testType__/__path__/__name__-test.js +2 -2
- package/blueprints/mixin/files/__root__/mixins/__name__.js +1 -2
- package/blueprints/mixin-test/mocha-files/__root__/__testType__/__name__-test.js +2 -2
- package/blueprints/mixin-test/mocha-rfc-232-files/__root__/__testType__/__name__-test.js +2 -2
- package/blueprints/mixin-test/qunit-files/__root__/__testType__/__name__-test.js +1 -1
- package/blueprints/mixin-test/qunit-rfc-232-files/__root__/__testType__/__name__-test.js +1 -1
- package/blueprints/route/files/__root__/__path__/__name__.js +2 -2
- package/blueprints/route-test/mocha-0.12-files/__root__/__testType__/__path__/__test__.js +2 -2
- package/blueprints/route-test/mocha-files/__root__/__testType__/__path__/__test__.js +5 -3
- package/blueprints/route-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js +2 -2
- package/blueprints/route-test/qunit-files/__root__/__testType__/__path__/__test__.js +1 -1
- package/blueprints/route-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js +2 -2
- package/blueprints/service/files/__root__/__path__/__name__.js +1 -2
- package/blueprints/service-test/mocha-0.12-files/__root__/__testType__/__path__/__test__.js +2 -2
- package/blueprints/service-test/mocha-files/__root__/__testType__/__path__/__test__.js +5 -3
- package/blueprints/service-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js +2 -2
- package/blueprints/service-test/qunit-files/__root__/__testType__/__path__/__test__.js +1 -1
- package/blueprints/service-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js +2 -2
- package/blueprints/util-test/mocha-files/__root__/__testType__/__name__-test.js +2 -2
- package/blueprints/util-test/mocha-rfc-232-files/__root__/__testType__/__name__-test.js +2 -2
- package/blueprints/util-test/qunit-files/__root__/__testType__/__name__-test.js +1 -1
- package/blueprints/util-test/qunit-rfc-232-files/__root__/__testType__/__name__-test.js +2 -3
- package/build-metadata.json +3 -3
- package/dist/dependencies/router_js.js +67 -32
- package/dist/ember-template-compiler.js +1168 -908
- package/dist/ember-template-compiler.map +1 -1
- package/dist/ember-testing.js +76 -43
- package/dist/ember-testing.map +1 -1
- package/dist/ember.debug.js +3206 -2734
- package/dist/ember.debug.map +1 -1
- package/dist/header/license.js +1 -1
- package/dist/packages/@ember/-internals/container/index.js +18 -13
- package/dist/packages/@ember/-internals/glimmer/index.js +128 -67
- package/dist/packages/@ember/-internals/meta/lib/meta.js +8 -9
- package/dist/packages/@ember/-internals/metal/index.js +58 -61
- package/dist/packages/@ember/-internals/routing/lib/ext/controller.js +10 -8
- package/dist/packages/@ember/-internals/routing/lib/services/router.js +155 -191
- package/dist/packages/@ember/-internals/routing/lib/services/routing.js +2 -0
- package/dist/packages/@ember/-internals/routing/lib/system/generate_controller.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 +108 -380
- package/dist/packages/@ember/-internals/routing/lib/system/router.js +65 -46
- package/dist/packages/@ember/-internals/routing/lib/utils.js +33 -21
- package/dist/packages/@ember/-internals/runtime/lib/mixins/action_handler.js +32 -32
- package/dist/packages/@ember/-internals/runtime/lib/mixins/container_proxy.js +29 -29
- package/dist/packages/@ember/-internals/runtime/lib/mixins/registry_proxy.js +51 -50
- package/dist/packages/@ember/-internals/utils/index.js +3 -1
- package/dist/packages/@ember/-internals/views/lib/system/utils.js +1 -0
- package/dist/packages/@ember/application/instance.js +3 -3
- package/dist/packages/@ember/canary-features/index.js +0 -10
- package/dist/packages/@ember/controller/index.js +3 -54
- package/dist/packages/@ember/debug/lib/capture-render-tree.js +2 -0
- package/dist/packages/@ember/instrumentation/index.js +9 -13
- package/dist/packages/@ember/routing/router-service.js +1 -0
- package/dist/packages/@ember/service/index.js +6 -73
- package/dist/packages/ember/index.js +3 -14
- package/dist/packages/ember/version.js +1 -1
- package/docs/data.json +556 -504
- package/package.json +13 -13
|
@@ -16,62 +16,62 @@ export default Mixin.create({
|
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
Given a fullName return the corresponding factory.
|
|
19
|
-
|
|
19
|
+
@public
|
|
20
20
|
@method resolveRegistration
|
|
21
21
|
@param {String} fullName
|
|
22
22
|
@return {Function} fullName's factory
|
|
23
23
|
*/
|
|
24
|
-
resolveRegistration(fullName
|
|
24
|
+
resolveRegistration(fullName) {
|
|
25
25
|
assert('fullName must be a proper full name', this.__registry__.isValidFullName(fullName));
|
|
26
|
-
return this.__registry__.resolve(fullName
|
|
26
|
+
return this.__registry__.resolve(fullName);
|
|
27
27
|
},
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
Registers a factory that can be used for dependency injection (with
|
|
31
31
|
`inject`) or for service lookup. Each factory is registered with
|
|
32
32
|
a full name including two parts: `type:name`.
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
A simple example:
|
|
34
|
+
```javascript
|
|
35
35
|
import Application from '@ember/application';
|
|
36
36
|
import EmberObject from '@ember/object';
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
let App = Application.create();
|
|
38
|
+
App.Orange = EmberObject.extend();
|
|
39
39
|
App.register('fruit:favorite', App.Orange);
|
|
40
40
|
```
|
|
41
|
-
|
|
41
|
+
Ember will resolve factories from the `App` namespace automatically.
|
|
42
42
|
For example `App.CarsController` will be discovered and returned if
|
|
43
43
|
an application requests `controller:cars`.
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
An example of registering a controller with a non-standard name:
|
|
45
|
+
```javascript
|
|
46
46
|
import Application from '@ember/application';
|
|
47
47
|
import Controller from '@ember/controller';
|
|
48
|
-
|
|
48
|
+
let App = Application.create();
|
|
49
49
|
let Session = Controller.extend();
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
App.register('controller:session', Session);
|
|
51
|
+
// The Session controller can now be treated like a normal controller,
|
|
52
52
|
// despite its non-standard name.
|
|
53
53
|
App.ApplicationController = Controller.extend({
|
|
54
54
|
needs: ['session']
|
|
55
55
|
});
|
|
56
56
|
```
|
|
57
|
-
|
|
57
|
+
Registered factories are **instantiated** by having `create`
|
|
58
58
|
called on them. Additionally they are **singletons**, each time
|
|
59
59
|
they are looked up they return the same instance.
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
Some examples modifying that default behavior:
|
|
61
|
+
```javascript
|
|
62
62
|
import Application from '@ember/application';
|
|
63
63
|
import EmberObject from '@ember/object';
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
let App = Application.create();
|
|
65
|
+
App.Person = EmberObject.extend();
|
|
66
66
|
App.Orange = EmberObject.extend();
|
|
67
67
|
App.Email = EmberObject.extend();
|
|
68
68
|
App.session = EmberObject.create();
|
|
69
|
-
|
|
69
|
+
App.register('model:user', App.Person, { singleton: false });
|
|
70
70
|
App.register('fruit:favorite', App.Orange);
|
|
71
71
|
App.register('communication:main', App.Email, { singleton: false });
|
|
72
72
|
App.register('session', App.session, { instantiate: false });
|
|
73
73
|
```
|
|
74
|
-
|
|
74
|
+
@method register
|
|
75
75
|
@param fullName {String} type:name (e.g., 'model:user')
|
|
76
76
|
@param factory {any} (e.g., App.Person)
|
|
77
77
|
@param options {Object} (optional) disable instantiation or singleton usage
|
|
@@ -81,17 +81,17 @@ export default Mixin.create({
|
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
83
|
Unregister a factory.
|
|
84
|
-
|
|
84
|
+
```javascript
|
|
85
85
|
import Application from '@ember/application';
|
|
86
86
|
import EmberObject from '@ember/object';
|
|
87
|
-
|
|
87
|
+
let App = Application.create();
|
|
88
88
|
let User = EmberObject.extend();
|
|
89
89
|
App.register('model:user', User);
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
App.resolveRegistration('model:user').create() instanceof User //=> true
|
|
91
|
+
App.unregister('model:user')
|
|
92
92
|
App.resolveRegistration('model:user') === undefined //=> true
|
|
93
93
|
```
|
|
94
|
-
|
|
94
|
+
@public
|
|
95
95
|
@method unregister
|
|
96
96
|
@param {String} fullName
|
|
97
97
|
*/
|
|
@@ -99,7 +99,7 @@ export default Mixin.create({
|
|
|
99
99
|
|
|
100
100
|
/**
|
|
101
101
|
Check if a factory is registered.
|
|
102
|
-
|
|
102
|
+
@public
|
|
103
103
|
@method hasRegistration
|
|
104
104
|
@param {String} fullName
|
|
105
105
|
@return {Boolean}
|
|
@@ -108,7 +108,7 @@ export default Mixin.create({
|
|
|
108
108
|
|
|
109
109
|
/**
|
|
110
110
|
Return a specific registered option for a particular factory.
|
|
111
|
-
|
|
111
|
+
@public
|
|
112
112
|
@method registeredOption
|
|
113
113
|
@param {String} fullName
|
|
114
114
|
@param {String} optionName
|
|
@@ -118,7 +118,7 @@ export default Mixin.create({
|
|
|
118
118
|
|
|
119
119
|
/**
|
|
120
120
|
Register options for a particular factory.
|
|
121
|
-
|
|
121
|
+
@public
|
|
122
122
|
@method registerOptions
|
|
123
123
|
@param {String} fullName
|
|
124
124
|
@param {Object} options
|
|
@@ -127,7 +127,7 @@ export default Mixin.create({
|
|
|
127
127
|
|
|
128
128
|
/**
|
|
129
129
|
Return registered options for a particular factory.
|
|
130
|
-
|
|
130
|
+
@public
|
|
131
131
|
@method registeredOptions
|
|
132
132
|
@param {String} fullName
|
|
133
133
|
@return {Object} options
|
|
@@ -136,22 +136,22 @@ export default Mixin.create({
|
|
|
136
136
|
|
|
137
137
|
/**
|
|
138
138
|
Allow registering options for all factories of a type.
|
|
139
|
-
|
|
139
|
+
```javascript
|
|
140
140
|
import Application from '@ember/application';
|
|
141
|
-
|
|
141
|
+
let App = Application.create();
|
|
142
142
|
let appInstance = App.buildInstance();
|
|
143
|
-
|
|
143
|
+
// if all of type `connection` must not be singletons
|
|
144
144
|
appInstance.registerOptionsForType('connection', { singleton: false });
|
|
145
|
-
|
|
145
|
+
appInstance.register('connection:twitter', TwitterConnection);
|
|
146
146
|
appInstance.register('connection:facebook', FacebookConnection);
|
|
147
|
-
|
|
147
|
+
let twitter = appInstance.lookup('connection:twitter');
|
|
148
148
|
let twitter2 = appInstance.lookup('connection:twitter');
|
|
149
|
-
|
|
150
|
-
|
|
149
|
+
twitter === twitter2; // => false
|
|
150
|
+
let facebook = appInstance.lookup('connection:facebook');
|
|
151
151
|
let facebook2 = appInstance.lookup('connection:facebook');
|
|
152
|
-
|
|
152
|
+
facebook === facebook2; // => false
|
|
153
153
|
```
|
|
154
|
-
|
|
154
|
+
@public
|
|
155
155
|
@method registerOptionsForType
|
|
156
156
|
@param {String} type
|
|
157
157
|
@param {Object} options
|
|
@@ -160,7 +160,7 @@ export default Mixin.create({
|
|
|
160
160
|
|
|
161
161
|
/**
|
|
162
162
|
Return the registered options for all factories of a type.
|
|
163
|
-
|
|
163
|
+
@public
|
|
164
164
|
@method registeredOptionsForType
|
|
165
165
|
@param {String} type
|
|
166
166
|
@return {Object} options
|
|
@@ -170,41 +170,42 @@ export default Mixin.create({
|
|
|
170
170
|
/**
|
|
171
171
|
Define a dependency injection onto a specific factory or all factories
|
|
172
172
|
of a type.
|
|
173
|
-
|
|
173
|
+
When Ember instantiates a controller, view, or other framework component
|
|
174
174
|
it can attach a dependency to that component. This is often used to
|
|
175
175
|
provide services to a set of framework components.
|
|
176
|
-
|
|
177
|
-
|
|
176
|
+
An example of providing a session object to all controllers:
|
|
177
|
+
```javascript
|
|
178
178
|
import { alias } from '@ember/object/computed';
|
|
179
179
|
import Application from '@ember/application';
|
|
180
180
|
import Controller from '@ember/controller';
|
|
181
181
|
import EmberObject from '@ember/object';
|
|
182
|
-
|
|
182
|
+
let App = Application.create();
|
|
183
183
|
let Session = EmberObject.extend({ isAuthenticated: false });
|
|
184
|
-
|
|
184
|
+
// A factory must be registered before it can be injected
|
|
185
185
|
App.register('session:main', Session);
|
|
186
|
-
|
|
186
|
+
// Inject 'session:main' onto all factories of the type 'controller'
|
|
187
187
|
// with the name 'session'
|
|
188
188
|
App.inject('controller', 'session', 'session:main');
|
|
189
|
-
|
|
189
|
+
App.IndexController = Controller.extend({
|
|
190
190
|
isLoggedIn: alias('session.isAuthenticated')
|
|
191
191
|
});
|
|
192
192
|
```
|
|
193
|
-
|
|
194
|
-
|
|
193
|
+
Injections can also be performed on specific factories.
|
|
194
|
+
```javascript
|
|
195
195
|
App.inject(<full_name or type>, <property name>, <full_name>)
|
|
196
196
|
App.inject('route', 'source', 'source:main')
|
|
197
197
|
App.inject('route:application', 'email', 'model:email')
|
|
198
198
|
```
|
|
199
|
-
|
|
199
|
+
It is important to note that injections can only be performed on
|
|
200
200
|
classes that are instantiated by Ember itself. Instantiating a class
|
|
201
201
|
directly (via `create` or `new`) bypasses the dependency injection
|
|
202
202
|
system.
|
|
203
|
-
|
|
203
|
+
@public
|
|
204
204
|
@method inject
|
|
205
205
|
@param factoryNameOrType {String}
|
|
206
206
|
@param property {String}
|
|
207
207
|
@param injectionName {String}
|
|
208
|
+
@deprecated
|
|
208
209
|
**/
|
|
209
210
|
inject: registryAlias('injection')
|
|
210
211
|
});
|
|
@@ -507,6 +507,8 @@ function inspectObject(obj, depth, seen) {
|
|
|
507
507
|
}
|
|
508
508
|
|
|
509
509
|
let key = keys[i];
|
|
510
|
+
assert('has key', key); // Looping over array
|
|
511
|
+
|
|
510
512
|
s += `${inspectKey(key)}: ${inspectValue(obj[key], depth, seen)}`;
|
|
511
513
|
}
|
|
512
514
|
|
|
@@ -571,7 +573,7 @@ function lookupDescriptor(obj, keyName) {
|
|
|
571
573
|
@private
|
|
572
574
|
*/
|
|
573
575
|
function canInvoke(obj, methodName) {
|
|
574
|
-
return obj
|
|
576
|
+
return obj != null && typeof obj[methodName] === 'function';
|
|
575
577
|
}
|
|
576
578
|
/**
|
|
577
579
|
@module @ember/utils
|
|
@@ -308,12 +308,12 @@ class BootOptions {
|
|
|
308
308
|
@default auto-detected
|
|
309
309
|
@private
|
|
310
310
|
*/
|
|
311
|
-
this.isInteractive = environment.hasDOM; // This default is overridable below
|
|
311
|
+
this.isInteractive = Boolean(environment.hasDOM); // This default is overridable below
|
|
312
312
|
|
|
313
313
|
/**
|
|
314
314
|
@property _renderMode
|
|
315
315
|
@type string
|
|
316
|
-
@default
|
|
316
|
+
@default undefined
|
|
317
317
|
@private
|
|
318
318
|
*/
|
|
319
319
|
|
|
@@ -340,7 +340,7 @@ class BootOptions {
|
|
|
340
340
|
if (options.isBrowser !== undefined) {
|
|
341
341
|
this.isBrowser = Boolean(options.isBrowser);
|
|
342
342
|
} else {
|
|
343
|
-
this.isBrowser = environment.hasDOM;
|
|
343
|
+
this.isBrowser = Boolean(environment.hasDOM);
|
|
344
344
|
}
|
|
345
345
|
|
|
346
346
|
if (!this.isBrowser) {
|
|
@@ -13,11 +13,6 @@ import { ENV } from '@ember/-internals/environment';
|
|
|
13
13
|
export const DEFAULT_FEATURES = {
|
|
14
14
|
EMBER_LIBRARIES_ISREGISTERED: null,
|
|
15
15
|
EMBER_IMPROVED_INSTRUMENTATION: null,
|
|
16
|
-
EMBER_NAMED_BLOCKS: true,
|
|
17
|
-
EMBER_GLIMMER_HELPER_MANAGER: true,
|
|
18
|
-
EMBER_GLIMMER_INVOKE_HELPER: true,
|
|
19
|
-
EMBER_STRICT_MODE: true,
|
|
20
|
-
EMBER_DYNAMIC_HELPERS_AND_MODIFIERS: true,
|
|
21
16
|
EMBER_ROUTING_ROUTER_SERVICE_REFRESH: true,
|
|
22
17
|
EMBER_CACHED: true
|
|
23
18
|
};
|
|
@@ -70,10 +65,5 @@ function featureValue(value) {
|
|
|
70
65
|
|
|
71
66
|
export const EMBER_LIBRARIES_ISREGISTERED = featureValue(FEATURES.EMBER_LIBRARIES_ISREGISTERED);
|
|
72
67
|
export const EMBER_IMPROVED_INSTRUMENTATION = featureValue(FEATURES.EMBER_IMPROVED_INSTRUMENTATION);
|
|
73
|
-
export const EMBER_NAMED_BLOCKS = featureValue(FEATURES.EMBER_NAMED_BLOCKS);
|
|
74
|
-
export const EMBER_GLIMMER_HELPER_MANAGER = featureValue(FEATURES.EMBER_GLIMMER_HELPER_MANAGER);
|
|
75
|
-
export const EMBER_GLIMMER_INVOKE_HELPER = featureValue(FEATURES.EMBER_GLIMMER_INVOKE_HELPER);
|
|
76
|
-
export const EMBER_STRICT_MODE = featureValue(FEATURES.EMBER_STRICT_MODE);
|
|
77
|
-
export const EMBER_DYNAMIC_HELPERS_AND_MODIFIERS = featureValue(FEATURES.EMBER_DYNAMIC_HELPERS_AND_MODIFIERS);
|
|
78
68
|
export const EMBER_ROUTING_ROUTER_SERVICE_REFRESH = featureValue(FEATURES.EMBER_ROUTING_ROUTER_SERVICE_REFRESH);
|
|
79
69
|
export const EMBER_CACHED = featureValue(FEATURES.EMBER_CACHED);
|
|
@@ -1,61 +1,10 @@
|
|
|
1
1
|
import { FrameworkObject } from '@ember/-internals/runtime';
|
|
2
2
|
import { inject as metalInject } from '@ember/-internals/metal';
|
|
3
3
|
import ControllerMixin from './lib/controller_mixin';
|
|
4
|
-
/**
|
|
5
|
-
@module @ember/controller
|
|
6
|
-
*/
|
|
7
4
|
|
|
8
|
-
|
|
9
|
-
@class Controller
|
|
10
|
-
@extends EmberObject
|
|
11
|
-
@uses Ember.ControllerMixin
|
|
12
|
-
@public
|
|
13
|
-
*/
|
|
5
|
+
class Controller extends FrameworkObject.extend(ControllerMixin) {}
|
|
14
6
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
Creates a property that lazily looks up another controller in the container.
|
|
18
|
-
Can only be used when defining another controller.
|
|
19
|
-
|
|
20
|
-
Example:
|
|
21
|
-
|
|
22
|
-
```app/controllers/post.js
|
|
23
|
-
import Controller, {
|
|
24
|
-
inject as controller
|
|
25
|
-
} from '@ember/controller';
|
|
26
|
-
|
|
27
|
-
export default class PostController extends Controller {
|
|
28
|
-
@controller posts;
|
|
29
|
-
}
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
Classic Class Example:
|
|
33
|
-
|
|
34
|
-
```app/controllers/post.js
|
|
35
|
-
import Controller, {
|
|
36
|
-
inject as controller
|
|
37
|
-
} from '@ember/controller';
|
|
38
|
-
|
|
39
|
-
export default Controller.extend({
|
|
40
|
-
posts: controller()
|
|
41
|
-
});
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
This example will create a `posts` property on the `post` controller that
|
|
45
|
-
looks up the `posts` controller in the container, making it easy to reference
|
|
46
|
-
other controllers.
|
|
47
|
-
|
|
48
|
-
@method inject
|
|
49
|
-
@static
|
|
50
|
-
@for @ember/controller
|
|
51
|
-
@since 1.10.0
|
|
52
|
-
@param {String} name (optional) name of the controller to inject, defaults to
|
|
53
|
-
the property's name
|
|
54
|
-
@return {ComputedDecorator} injection decorator instance
|
|
55
|
-
@public
|
|
56
|
-
*/
|
|
57
|
-
|
|
58
|
-
export function inject() {
|
|
59
|
-
return metalInject('controller', ...arguments);
|
|
7
|
+
export function inject(...args) {
|
|
8
|
+
return metalInject('controller', ...args);
|
|
60
9
|
}
|
|
61
10
|
export default Controller;
|
|
@@ -18,6 +18,8 @@ import { expect } from '@glimmer/util';
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
export default function captureRenderTree(app) {
|
|
21
|
+
// SAFETY: Ideally we'd assert here but that causes awkward circular requires since this is also in @ember/debug.
|
|
22
|
+
// This is only for debug stuff so not very risky.
|
|
21
23
|
let renderer = expect(app.lookup('renderer:-dom'), `BUG: owner is missing renderer`);
|
|
22
24
|
return renderer.debugRenderTree.capture();
|
|
23
25
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
/* global console */
|
|
4
4
|
import { ENV } from '@ember/-internals/environment';
|
|
5
|
-
|
|
5
|
+
import { assert } from '@ember/debug';
|
|
6
6
|
/**
|
|
7
7
|
@module @ember/instrumentation
|
|
8
8
|
@private
|
|
@@ -58,16 +58,14 @@ import { ENV } from '@ember/-internals/environment';
|
|
|
58
58
|
@static
|
|
59
59
|
@private
|
|
60
60
|
*/
|
|
61
|
+
|
|
61
62
|
export let subscribers = [];
|
|
62
63
|
let cache = {};
|
|
63
64
|
|
|
64
65
|
function populateListeners(name) {
|
|
65
66
|
let listeners = [];
|
|
66
|
-
let subscriber;
|
|
67
|
-
|
|
68
|
-
for (let i = 0; i < subscribers.length; i++) {
|
|
69
|
-
subscriber = subscribers[i];
|
|
70
67
|
|
|
68
|
+
for (let subscriber of subscribers) {
|
|
71
69
|
if (subscriber.regex.test(name)) {
|
|
72
70
|
listeners.push(subscriber.object);
|
|
73
71
|
}
|
|
@@ -172,16 +170,17 @@ export function _instrumentStart(name, payloadFunc, payloadArg) {
|
|
|
172
170
|
let beforeValues = [];
|
|
173
171
|
let timestamp = time();
|
|
174
172
|
|
|
175
|
-
for (let
|
|
176
|
-
let listener = listeners[i];
|
|
173
|
+
for (let listener of listeners) {
|
|
177
174
|
beforeValues.push(listener.before(name, timestamp, payload));
|
|
178
175
|
}
|
|
179
176
|
|
|
177
|
+
const constListeners = listeners;
|
|
180
178
|
return function _instrumentEnd() {
|
|
181
179
|
let timestamp = time();
|
|
182
180
|
|
|
183
|
-
for (let i = 0; i <
|
|
184
|
-
let listener =
|
|
181
|
+
for (let i = 0; i < constListeners.length; i++) {
|
|
182
|
+
let listener = constListeners[i];
|
|
183
|
+
assert('has listener', listener); // Iterating over values
|
|
185
184
|
|
|
186
185
|
if (typeof listener.after === 'function') {
|
|
187
186
|
listener.after(name, timestamp, payload, beforeValues[i]);
|
|
@@ -209,12 +208,9 @@ export function _instrumentStart(name, payloadFunc, payloadArg) {
|
|
|
209
208
|
|
|
210
209
|
export function subscribe(pattern, object) {
|
|
211
210
|
let paths = pattern.split('.');
|
|
212
|
-
let path;
|
|
213
211
|
let regexes = [];
|
|
214
212
|
|
|
215
|
-
for (let
|
|
216
|
-
path = paths[i];
|
|
217
|
-
|
|
213
|
+
for (let path of paths) {
|
|
218
214
|
if (path === '*') {
|
|
219
215
|
regexes.push('[^\\.]*');
|
|
220
216
|
} else {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { RouterService as default } from '@ember/-internals/routing';
|
|
@@ -1,74 +1,10 @@
|
|
|
1
1
|
import { FrameworkObject } from '@ember/-internals/runtime';
|
|
2
2
|
import { inject as metalInject } from '@ember/-internals/metal';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
@public
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
@method inject
|
|
10
|
-
@static
|
|
11
|
-
@since 1.10.0
|
|
12
|
-
@for @ember/service
|
|
13
|
-
@param {String} name (optional) name of the service to inject, defaults to
|
|
14
|
-
the property's name
|
|
15
|
-
@return {ComputedDecorator} injection decorator instance
|
|
16
|
-
@public
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
export function inject() {
|
|
20
|
-
return metalInject('service', ...arguments);
|
|
3
|
+
export function inject(...args) {
|
|
4
|
+
return metalInject('service', ...args);
|
|
21
5
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
no restrictions as to what objects a service can be injected into.
|
|
25
|
-
|
|
26
|
-
Example:
|
|
27
|
-
|
|
28
|
-
```app/routes/application.js
|
|
29
|
-
import Route from '@ember/routing/route';
|
|
30
|
-
import { service } from '@ember/service';
|
|
31
|
-
|
|
32
|
-
export default class ApplicationRoute extends Route {
|
|
33
|
-
@service('auth') authManager;
|
|
34
|
-
|
|
35
|
-
model() {
|
|
36
|
-
return this.authManager.findCurrentUser();
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
Classic Class Example:
|
|
42
|
-
|
|
43
|
-
```app/routes/application.js
|
|
44
|
-
import Route from '@ember/routing/route';
|
|
45
|
-
import { service } from '@ember/service';
|
|
46
|
-
|
|
47
|
-
export default Route.extend({
|
|
48
|
-
authManager: service('auth'),
|
|
49
|
-
|
|
50
|
-
model() {
|
|
51
|
-
return this.get('authManager').findCurrentUser();
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
This example will create an `authManager` property on the application route
|
|
57
|
-
that looks up the `auth` service in the container, making it easily accessible
|
|
58
|
-
in the `model` hook.
|
|
59
|
-
|
|
60
|
-
@method service
|
|
61
|
-
@static
|
|
62
|
-
@since 4.1.0
|
|
63
|
-
@for @ember/service
|
|
64
|
-
@param {String} name (optional) name of the service to inject, defaults to
|
|
65
|
-
the property's name
|
|
66
|
-
@return {ComputedDecorator} injection decorator instance
|
|
67
|
-
@public
|
|
68
|
-
*/
|
|
69
|
-
|
|
70
|
-
export function service() {
|
|
71
|
-
return metalInject('service', ...arguments);
|
|
6
|
+
export function service(...args) {
|
|
7
|
+
return metalInject('service', ...args);
|
|
72
8
|
}
|
|
73
9
|
/**
|
|
74
10
|
@class Service
|
|
@@ -77,8 +13,5 @@ export function service() {
|
|
|
77
13
|
@public
|
|
78
14
|
*/
|
|
79
15
|
|
|
80
|
-
|
|
81
|
-
Service.
|
|
82
|
-
isServiceFactory: true
|
|
83
|
-
});
|
|
84
|
-
export default Service;
|
|
16
|
+
export default class Service extends FrameworkObject {}
|
|
17
|
+
Service.isServiceFactory = true;
|
|
@@ -313,20 +313,9 @@ Ember._concat = concat;
|
|
|
313
313
|
Ember._get = get;
|
|
314
314
|
Ember._on = on;
|
|
315
315
|
Ember._fn = fn;
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
) {
|
|
320
|
-
Ember._helperManagerCapabilities = helperCapabilities;
|
|
321
|
-
Ember._setHelperManager = setHelperManager;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
if (true
|
|
325
|
-
/* EMBER_GLIMMER_INVOKE_HELPER */
|
|
326
|
-
) {
|
|
327
|
-
Ember._invokeHelper = invokeHelper;
|
|
328
|
-
}
|
|
329
|
-
|
|
316
|
+
Ember._helperManagerCapabilities = helperCapabilities;
|
|
317
|
+
Ember._setHelperManager = setHelperManager;
|
|
318
|
+
Ember._invokeHelper = invokeHelper;
|
|
330
319
|
Ember._captureRenderTree = captureRenderTree;
|
|
331
320
|
|
|
332
321
|
const deprecateImportFromString = function (name, message = `Importing ${name} from '@ember/string' is deprecated. Please import ${name} from '@ember/template' instead.`) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default "4.
|
|
1
|
+
export default "4.4.0-alpha.2";
|