ember-source 4.4.0-alpha.1 → 4.4.0-alpha.4
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 +5 -1
- 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 +3 -3
- 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 +3 -3
- 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 +6 -6
- 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 +6 -6
- 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 +3 -3
- 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 +3 -3
- 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 +3 -3
- 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 +3 -3
- 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 +3 -3
- 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 +3 -3
- 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 +3 -3
- 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 +3 -3
- 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 +1 -1
- package/dist/ember-template-compiler.js +20 -143
- package/dist/ember-template-compiler.map +1 -1
- package/dist/ember-testing.js +5 -3
- package/dist/ember-testing.map +1 -1
- package/dist/ember.debug.js +1132 -1719
- package/dist/ember.debug.map +1 -1
- package/dist/header/license.js +1 -1
- package/dist/packages/@ember/-internals/container/index.js +3 -19
- package/dist/packages/@ember/-internals/extension-support/lib/container_debug_adapter.js +10 -19
- package/dist/packages/@ember/-internals/extension-support/lib/data_adapter.js +113 -112
- package/dist/packages/@ember/-internals/glimmer/index.js +163 -773
- package/dist/packages/@ember/-internals/metal/index.js +19 -32
- package/dist/packages/@ember/-internals/routing/lib/location/hash_location.js +1 -1
- package/dist/packages/@ember/-internals/routing/lib/services/router.js +67 -12
- 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.js +15 -7
- package/dist/packages/@ember/-internals/routing/lib/system/router.js +16 -21
- package/dist/packages/@ember/-internals/routing/lib/utils.js +2 -1
- package/dist/packages/@ember/-internals/runtime/lib/compare.js +19 -5
- package/dist/packages/@ember/-internals/runtime/lib/ext/rsvp.js +8 -4
- package/dist/packages/@ember/-internals/runtime/lib/mixins/-proxy.js +1 -1
- package/dist/packages/@ember/-internals/runtime/lib/mixins/array.js +1 -1
- 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 +51 -50
- package/dist/packages/@ember/-internals/runtime/lib/mixins/target_action_support.js +8 -8
- package/dist/packages/@ember/-internals/utils/index.js +1 -1
- package/dist/packages/@ember/-internals/views/lib/system/utils.js +4 -2
- package/dist/packages/@ember/-internals/views/lib/views/core_view.js +5 -22
- package/dist/packages/@ember/application/instance.js +3 -3
- package/dist/packages/@ember/canary-features/index.js +4 -12
- package/dist/packages/@ember/debug/index.js +1 -1
- package/dist/packages/@ember/debug/lib/capture-render-tree.js +2 -0
- package/dist/packages/@ember/debug/lib/handlers.js +1 -1
- package/dist/packages/@ember/renderer/index.js +21 -0
- package/dist/packages/@ember/runloop/index.js +31 -528
- package/dist/packages/@ember/runloop/type-tests.ts/begin-end.test.js +5 -0
- package/dist/packages/@ember/runloop/type-tests.ts/bind.test.js +59 -0
- package/dist/packages/@ember/runloop/type-tests.ts/cancel.test.js +5 -0
- package/dist/packages/@ember/runloop/type-tests.ts/debounce.test.js +77 -0
- package/dist/packages/@ember/runloop/type-tests.ts/join.test.js +38 -0
- package/dist/packages/@ember/runloop/type-tests.ts/later.test.js +38 -0
- package/dist/packages/@ember/runloop/type-tests.ts/next.test.js +38 -0
- package/dist/packages/@ember/runloop/type-tests.ts/once.test.js +38 -0
- package/dist/packages/@ember/runloop/type-tests.ts/run.test.js +38 -0
- package/dist/packages/@ember/runloop/type-tests.ts/schedule-once.test.js +39 -0
- package/dist/packages/@ember/runloop/type-tests.ts/schedule.test.js +39 -0
- package/dist/packages/@ember/runloop/type-tests.ts/throttle.test.js +77 -0
- package/dist/packages/ember/index.js +4 -14
- package/dist/packages/ember/version.js +1 -1
- package/docs/data.json +658 -383
- package/package.json +10 -10
|
@@ -1351,7 +1351,7 @@ const MutableArray = Mixin.create(ArrayMixin, MutableEnumerable, {
|
|
|
1351
1351
|
colors.unshiftObjects('yellow'); // Type Error: 'undefined' is not a function
|
|
1352
1352
|
```
|
|
1353
1353
|
@method unshiftObjects
|
|
1354
|
-
@param {
|
|
1354
|
+
@param {Enumerable} objects the objects to add
|
|
1355
1355
|
@return {EmberArray} receiver
|
|
1356
1356
|
@public
|
|
1357
1357
|
*/
|
|
@@ -18,13 +18,13 @@ import { Mixin } from '@ember/-internals/metal';
|
|
|
18
18
|
export default Mixin.create({
|
|
19
19
|
/**
|
|
20
20
|
__Required.__ You must implement this method to apply this mixin.
|
|
21
|
-
|
|
21
|
+
Override to return the result of the comparison of the two parameters. The
|
|
22
22
|
compare method should return:
|
|
23
|
-
|
|
23
|
+
- `-1` if `a < b`
|
|
24
24
|
- `0` if `a == b`
|
|
25
25
|
- `1` if `a > b`
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
Default implementation raises an exception.
|
|
27
|
+
@method compare
|
|
28
28
|
@param a {Object} the first object to compare
|
|
29
29
|
@param b {Object} the second object to compare
|
|
30
30
|
@return {Number} the result of the comparison
|
|
@@ -15,7 +15,7 @@ import { Mixin } from '@ember/-internals/metal';
|
|
|
15
15
|
let containerProxyMixin = {
|
|
16
16
|
/**
|
|
17
17
|
The container stores state.
|
|
18
|
-
|
|
18
|
+
@private
|
|
19
19
|
@property {Ember.Container} __container__
|
|
20
20
|
*/
|
|
21
21
|
__container__: null,
|
|
@@ -23,16 +23,16 @@ let containerProxyMixin = {
|
|
|
23
23
|
/**
|
|
24
24
|
Returns an object that can be used to provide an owner to a
|
|
25
25
|
manually created instance.
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
Example:
|
|
27
|
+
```
|
|
28
28
|
import { getOwner } from '@ember/application';
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
let owner = getOwner(this);
|
|
30
|
+
User.create(
|
|
31
31
|
owner.ownerInjection(),
|
|
32
32
|
{ username: 'rwjblue' }
|
|
33
33
|
)
|
|
34
34
|
```
|
|
35
|
-
|
|
35
|
+
@public
|
|
36
36
|
@method ownerInjection
|
|
37
37
|
@since 2.3.0
|
|
38
38
|
@return {Object}
|
|
@@ -43,30 +43,30 @@ let containerProxyMixin = {
|
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
45
|
Given a fullName return a corresponding instance.
|
|
46
|
-
|
|
46
|
+
The default behavior is for lookup to return a singleton instance.
|
|
47
47
|
The singleton is scoped to the container, allowing multiple containers
|
|
48
48
|
to all have their own locally scoped singletons.
|
|
49
|
-
|
|
49
|
+
```javascript
|
|
50
50
|
let registry = new Registry();
|
|
51
51
|
let container = registry.container();
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
registry.register('api:twitter', Twitter);
|
|
53
|
+
let twitter = container.lookup('api:twitter');
|
|
54
|
+
twitter instanceof Twitter; // => true
|
|
55
|
+
// by default the container will return singletons
|
|
56
56
|
let twitter2 = container.lookup('api:twitter');
|
|
57
57
|
twitter2 instanceof Twitter; // => true
|
|
58
|
-
|
|
58
|
+
twitter === twitter2; //=> true
|
|
59
59
|
```
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
If singletons are not wanted an optional flag can be provided at lookup.
|
|
61
|
+
```javascript
|
|
62
62
|
let registry = new Registry();
|
|
63
63
|
let container = registry.container();
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
registry.register('api:twitter', Twitter);
|
|
65
|
+
let twitter = container.lookup('api:twitter', { singleton: false });
|
|
66
66
|
let twitter2 = container.lookup('api:twitter', { singleton: false });
|
|
67
|
-
|
|
67
|
+
twitter === twitter2; //=> false
|
|
68
68
|
```
|
|
69
|
-
|
|
69
|
+
@public
|
|
70
70
|
@method lookup
|
|
71
71
|
@param {String} fullName
|
|
72
72
|
@param {Object} options
|
|
@@ -91,32 +91,32 @@ let containerProxyMixin = {
|
|
|
91
91
|
|
|
92
92
|
/**
|
|
93
93
|
Given a fullName return a factory manager.
|
|
94
|
-
|
|
94
|
+
This method returns a manager which can be used for introspection of the
|
|
95
95
|
factory's class or for the creation of factory instances with initial
|
|
96
96
|
properties. The manager is an object with the following properties:
|
|
97
|
-
|
|
97
|
+
* `class` - The registered or resolved class.
|
|
98
98
|
* `create` - A function that will create an instance of the class with
|
|
99
99
|
any dependencies injected.
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
For example:
|
|
101
|
+
```javascript
|
|
102
102
|
import { getOwner } from '@ember/application';
|
|
103
|
-
|
|
103
|
+
let owner = getOwner(otherInstance);
|
|
104
104
|
// the owner is commonly the `applicationInstance`, and can be accessed via
|
|
105
105
|
// an instance initializer.
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
let factory = owner.factoryFor('service:bespoke');
|
|
107
|
+
factory.class;
|
|
108
108
|
// The registered or resolved class. For example when used with an Ember-CLI
|
|
109
109
|
// app, this would be the default export from `app/services/bespoke.js`.
|
|
110
|
-
|
|
110
|
+
let instance = factory.create({
|
|
111
111
|
someProperty: 'an initial property value'
|
|
112
112
|
});
|
|
113
113
|
// Create an instance with any injections and the passed options as
|
|
114
114
|
// initial properties.
|
|
115
115
|
```
|
|
116
|
-
|
|
116
|
+
Any instances created via the factory's `.create()` method *must* be destroyed
|
|
117
117
|
manually by the caller of `.create()`. Typically, this is done during the creating
|
|
118
118
|
objects own `destroy` or `willDestroy` methods.
|
|
119
|
-
|
|
119
|
+
@public
|
|
120
120
|
@method factoryFor
|
|
121
121
|
@param {String} fullName
|
|
122
122
|
@param {Object} options
|
|
@@ -98,7 +98,7 @@ export default Mixin.create({
|
|
|
98
98
|
/**
|
|
99
99
|
If the proxied promise is rejected this will contain the reason
|
|
100
100
|
provided.
|
|
101
|
-
|
|
101
|
+
@property reason
|
|
102
102
|
@default null
|
|
103
103
|
@public
|
|
104
104
|
*/
|
|
@@ -106,7 +106,7 @@ export default Mixin.create({
|
|
|
106
106
|
|
|
107
107
|
/**
|
|
108
108
|
Once the proxied promise has settled this will become `false`.
|
|
109
|
-
|
|
109
|
+
@property isPending
|
|
110
110
|
@default true
|
|
111
111
|
@public
|
|
112
112
|
*/
|
|
@@ -116,7 +116,7 @@ export default Mixin.create({
|
|
|
116
116
|
|
|
117
117
|
/**
|
|
118
118
|
Once the proxied promise has settled this will become `true`.
|
|
119
|
-
|
|
119
|
+
@property isSettled
|
|
120
120
|
@default false
|
|
121
121
|
@public
|
|
122
122
|
*/
|
|
@@ -126,7 +126,7 @@ export default Mixin.create({
|
|
|
126
126
|
|
|
127
127
|
/**
|
|
128
128
|
Will become `true` if the proxied promise is rejected.
|
|
129
|
-
|
|
129
|
+
@property isRejected
|
|
130
130
|
@default false
|
|
131
131
|
@public
|
|
132
132
|
*/
|
|
@@ -134,7 +134,7 @@ export default Mixin.create({
|
|
|
134
134
|
|
|
135
135
|
/**
|
|
136
136
|
Will become `true` if the proxied promise is fulfilled.
|
|
137
|
-
|
|
137
|
+
@property isFulfilled
|
|
138
138
|
@default false
|
|
139
139
|
@public
|
|
140
140
|
*/
|
|
@@ -142,17 +142,17 @@ export default Mixin.create({
|
|
|
142
142
|
|
|
143
143
|
/**
|
|
144
144
|
The promise whose fulfillment value is being proxied by this object.
|
|
145
|
-
|
|
145
|
+
This property must be specified upon creation, and should not be
|
|
146
146
|
changed once created.
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
Example:
|
|
148
|
+
```javascript
|
|
149
149
|
import ObjectProxy from '@ember/object/proxy';
|
|
150
150
|
import PromiseProxyMixin from '@ember/object/promise-proxy-mixin';
|
|
151
|
-
|
|
151
|
+
ObjectProxy.extend(PromiseProxyMixin).create({
|
|
152
152
|
promise: <thenable>
|
|
153
153
|
});
|
|
154
154
|
```
|
|
155
|
-
|
|
155
|
+
@property promise
|
|
156
156
|
@public
|
|
157
157
|
*/
|
|
158
158
|
promise: computed({
|
|
@@ -168,8 +168,8 @@ export default Mixin.create({
|
|
|
168
168
|
|
|
169
169
|
/**
|
|
170
170
|
An alias to the proxied promise's `then`.
|
|
171
|
-
|
|
172
|
-
|
|
171
|
+
See RSVP.Promise.then.
|
|
172
|
+
@method then
|
|
173
173
|
@param {Function} callback
|
|
174
174
|
@return {RSVP.Promise}
|
|
175
175
|
@public
|
|
@@ -178,8 +178,8 @@ export default Mixin.create({
|
|
|
178
178
|
|
|
179
179
|
/**
|
|
180
180
|
An alias to the proxied promise's `catch`.
|
|
181
|
-
|
|
182
|
-
|
|
181
|
+
See RSVP.Promise.catch.
|
|
182
|
+
@method catch
|
|
183
183
|
@param {Function} callback
|
|
184
184
|
@return {RSVP.Promise}
|
|
185
185
|
@since 1.3.0
|
|
@@ -189,8 +189,8 @@ export default Mixin.create({
|
|
|
189
189
|
|
|
190
190
|
/**
|
|
191
191
|
An alias to the proxied promise's `finally`.
|
|
192
|
-
|
|
193
|
-
|
|
192
|
+
See RSVP.Promise.finally.
|
|
193
|
+
@method finally
|
|
194
194
|
@param {Function} callback
|
|
195
195
|
@return {RSVP.Promise}
|
|
196
196
|
@since 1.3.0
|
|
@@ -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
|
});
|
|
@@ -41,9 +41,9 @@ const TargetActionSupport = Mixin.create({
|
|
|
41
41
|
/**
|
|
42
42
|
Send an `action` with an `actionContext` to a `target`. The action, actionContext
|
|
43
43
|
and target will be retrieved from properties of the object. For example:
|
|
44
|
-
|
|
44
|
+
```javascript
|
|
45
45
|
import { alias } from '@ember/object/computed';
|
|
46
|
-
|
|
46
|
+
App.SaveButtonView = Ember.View.extend(Ember.TargetActionSupport, {
|
|
47
47
|
target: alias('controller'),
|
|
48
48
|
action: 'save',
|
|
49
49
|
actionContext: alias('context'),
|
|
@@ -53,9 +53,9 @@ const TargetActionSupport = Mixin.create({
|
|
|
53
53
|
}
|
|
54
54
|
});
|
|
55
55
|
```
|
|
56
|
-
|
|
56
|
+
The `target`, `action`, and `actionContext` can be provided as properties of
|
|
57
57
|
an optional object argument to `triggerAction` as well.
|
|
58
|
-
|
|
58
|
+
```javascript
|
|
59
59
|
App.SaveButtonView = Ember.View.extend(Ember.TargetActionSupport, {
|
|
60
60
|
click() {
|
|
61
61
|
this.triggerAction({
|
|
@@ -67,12 +67,12 @@ const TargetActionSupport = Mixin.create({
|
|
|
67
67
|
}
|
|
68
68
|
});
|
|
69
69
|
```
|
|
70
|
-
|
|
70
|
+
The `actionContext` defaults to the object you are mixing `TargetActionSupport` into.
|
|
71
71
|
But `target` and `action` must be specified either as properties or with the argument
|
|
72
72
|
to `triggerAction`, or a combination:
|
|
73
|
-
|
|
73
|
+
```javascript
|
|
74
74
|
import { alias } from '@ember/object/computed';
|
|
75
|
-
|
|
75
|
+
App.SaveButtonView = Ember.View.extend(Ember.TargetActionSupport, {
|
|
76
76
|
target: alias('controller'),
|
|
77
77
|
click() {
|
|
78
78
|
this.triggerAction({
|
|
@@ -82,7 +82,7 @@ const TargetActionSupport = Mixin.create({
|
|
|
82
82
|
}
|
|
83
83
|
});
|
|
84
84
|
```
|
|
85
|
-
|
|
85
|
+
@method triggerAction
|
|
86
86
|
@param opts {Object} (optional, with the optional keys action, target and/or actionContext)
|
|
87
87
|
@return {Boolean} true if the action was sent successfully and did not return false
|
|
88
88
|
@private
|
|
@@ -573,7 +573,7 @@ function lookupDescriptor(obj, keyName) {
|
|
|
573
573
|
@private
|
|
574
574
|
*/
|
|
575
575
|
function canInvoke(obj, methodName) {
|
|
576
|
-
return obj
|
|
576
|
+
return obj != null && typeof obj[methodName] === 'function';
|
|
577
577
|
}
|
|
578
578
|
/**
|
|
579
579
|
@module @ember/utils
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { getOwner } from '@ember/-internals/owner';
|
|
2
|
-
/* globals Element */
|
|
3
|
-
|
|
4
2
|
import { guidFor } from '@ember/-internals/utils';
|
|
5
3
|
import { assert } from '@ember/debug';
|
|
6
4
|
/**
|
|
@@ -8,6 +6,10 @@ import { assert } from '@ember/debug';
|
|
|
8
6
|
*/
|
|
9
7
|
|
|
10
8
|
export function isSimpleClick(event) {
|
|
9
|
+
if (!(event instanceof MouseEvent)) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
|
|
11
13
|
let modifier = event.shiftKey || event.metaKey || event.altKey || event.ctrlKey;
|
|
12
14
|
let secondaryClick = event.which > 1; // IE9 may return undefined
|
|
13
15
|
|
|
@@ -1,23 +1,6 @@
|
|
|
1
1
|
import { inject } from '@ember/-internals/metal';
|
|
2
2
|
import { ActionHandler, Evented, FrameworkObject } from '@ember/-internals/runtime';
|
|
3
3
|
import states from './states';
|
|
4
|
-
/**
|
|
5
|
-
`Ember.CoreView` is an abstract class that exists to give view-like behavior
|
|
6
|
-
to both Ember's main view class `Component` and other classes that don't need
|
|
7
|
-
the full functionality of `Component`.
|
|
8
|
-
|
|
9
|
-
Unless you have specific needs for `CoreView`, you will use `Component`
|
|
10
|
-
in your applications.
|
|
11
|
-
|
|
12
|
-
@class CoreView
|
|
13
|
-
@namespace Ember
|
|
14
|
-
@extends EmberObject
|
|
15
|
-
@deprecated Use `Component` instead.
|
|
16
|
-
@uses Evented
|
|
17
|
-
@uses Ember.ActionHandler
|
|
18
|
-
@private
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
4
|
const CoreView = FrameworkObject.extend(Evented, ActionHandler, {
|
|
22
5
|
isView: true,
|
|
23
6
|
_states: states,
|
|
@@ -34,7 +17,7 @@ const CoreView = FrameworkObject.extend(Evented, ActionHandler, {
|
|
|
34
17
|
/**
|
|
35
18
|
If the view is currently inserted into the DOM of a parent view, this
|
|
36
19
|
property will point to the parent of the view.
|
|
37
|
-
|
|
20
|
+
@property parentView
|
|
38
21
|
@type Ember.View
|
|
39
22
|
@default null
|
|
40
23
|
@private
|
|
@@ -42,16 +25,16 @@ const CoreView = FrameworkObject.extend(Evented, ActionHandler, {
|
|
|
42
25
|
parentView: null,
|
|
43
26
|
|
|
44
27
|
instrumentDetails(hash) {
|
|
45
|
-
hash
|
|
46
|
-
hash
|
|
47
|
-
hash
|
|
28
|
+
hash['object'] = this.toString();
|
|
29
|
+
hash['containerKey'] = this._debugContainerKey;
|
|
30
|
+
hash['view'] = this;
|
|
48
31
|
return hash;
|
|
49
32
|
},
|
|
50
33
|
|
|
51
34
|
/**
|
|
52
35
|
Override the default event firing from `Evented` to
|
|
53
36
|
also call methods with the given name.
|
|
54
|
-
|
|
37
|
+
@method trigger
|
|
55
38
|
@param name {String}
|
|
56
39
|
@private
|
|
57
40
|
*/
|
|
@@ -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) {
|