ember-source 3.28.5 → 4.0.0-beta.10
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 +113 -10
- package/blueprints/acceptance-test/qunit-files/tests/acceptance/__name__-test.js +1 -1
- package/blueprints/acceptance-test/qunit-rfc-232-files/tests/acceptance/__name__-test.js +1 -1
- package/blueprints/component-test/qunit-files/__root__/__testType__/__path__/__test__.js +3 -3
- package/blueprints/helper-test/index.js +4 -22
- package/blueprints/helper-test/mocha-0.12-files/__root__/__testType__/__collection__/__name__-test.js +1 -13
- package/blueprints/helper-test/mocha-files/__root__/__testType__/__collection__/__name__-test.js +0 -13
- package/blueprints/helper-test/mocha-rfc-232-files/__root__/__testType__/__collection__/__name__-test.js +2 -12
- package/blueprints/helper-test/qunit-files/__root__/__testType__/__collection__/__name__-test.js +2 -13
- package/blueprints/helper-test/qunit-rfc-232-files/__root__/__testType__/__collection__/__name__-test.js +2 -14
- package/blueprints/initializer/files/__root__/initializers/__name__.js +0 -1
- package/blueprints/instance-initializer/files/__root__/instance-initializers/__name__.js +0 -1
- package/build-metadata.json +3 -3
- package/dist/dependencies/@glimmer/manager.js +19 -98
- package/dist/dependencies/@glimmer/opcode-compiler.js +9 -146
- package/dist/dependencies/@glimmer/runtime.js +1 -55
- package/dist/dependencies/@glimmer/validator.js +19 -51
- package/dist/ember-template-compiler.js +3692 -5667
- package/dist/ember-template-compiler.map +1 -1
- package/dist/ember-testing.js +12 -560
- package/dist/ember-testing.map +1 -1
- package/dist/ember.debug.js +4357 -12470
- package/dist/ember.debug.map +1 -1
- package/dist/header/license.js +1 -1
- package/dist/packages/@ember/-internals/bootstrap/index.js +2 -55
- package/dist/packages/@ember/-internals/container/index.js +35 -206
- package/dist/packages/@ember/-internals/environment/index.js +3 -46
- package/dist/packages/@ember/-internals/extension-support/lib/container_debug_adapter.js +7 -0
- package/dist/packages/@ember/-internals/extension-support/lib/data_adapter.js +1 -2
- package/dist/packages/@ember/-internals/glimmer/index.js +4774 -7035
- package/dist/packages/@ember/-internals/meta/lib/meta.js +2 -50
- package/dist/packages/@ember/-internals/metal/index.js +785 -1109
- package/dist/packages/@ember/-internals/overrides/index.js +1 -3
- package/dist/packages/@ember/-internals/owner/index.js +1 -19
- package/dist/packages/@ember/-internals/routing/lib/location/auto_location.js +1 -51
- package/dist/packages/@ember/-internals/routing/lib/location/hash_location.js +1 -0
- package/dist/packages/@ember/-internals/routing/lib/location/history_location.js +3 -1
- package/dist/packages/@ember/-internals/routing/lib/location/none_location.js +0 -7
- package/dist/packages/@ember/-internals/routing/lib/services/router.js +34 -2
- package/dist/packages/@ember/-internals/routing/lib/services/routing.js +2 -3
- package/dist/packages/@ember/-internals/routing/lib/system/dsl.js +5 -6
- package/dist/packages/@ember/-internals/routing/lib/system/route.js +192 -652
- package/dist/packages/@ember/-internals/routing/lib/system/router.js +119 -248
- package/dist/packages/@ember/-internals/routing/lib/system/router_state.js +1 -2
- package/dist/packages/@ember/-internals/routing/lib/utils.js +1 -2
- package/dist/packages/@ember/-internals/runtime/index.js +1 -4
- package/dist/packages/@ember/-internals/runtime/lib/mixins/array.js +4 -175
- package/dist/packages/@ember/-internals/runtime/lib/mixins/observable.js +1 -18
- package/dist/packages/@ember/-internals/runtime/lib/mixins/target_action_support.js +3 -43
- package/dist/packages/@ember/-internals/runtime/lib/system/array_proxy.js +8 -15
- package/dist/packages/@ember/-internals/runtime/lib/system/core_object.js +10 -141
- package/dist/packages/@ember/-internals/utils/index.js +3 -59
- package/dist/packages/@ember/-internals/views/index.js +0 -2
- package/dist/packages/@ember/-internals/views/lib/mixins/action_support.js +1 -121
- package/dist/packages/@ember/-internals/views/lib/mixins/view_support.js +4 -40
- package/dist/packages/@ember/-internals/views/lib/system/event_dispatcher.js +115 -190
- package/dist/packages/@ember/-internals/views/lib/views/states/destroying.js +1 -2
- package/dist/packages/@ember/-internals/views/lib/views/states/has_element.js +1 -2
- package/dist/packages/@ember/-internals/views/lib/views/states/in_dom.js +1 -2
- package/dist/packages/@ember/-internals/views/lib/views/states/pre_render.js +1 -2
- package/dist/packages/@ember/application/instance.js +3 -25
- package/dist/packages/@ember/application/lib/application.js +14 -32
- package/dist/packages/@ember/canary-features/index.js +5 -6
- package/dist/packages/@ember/component/index.js +1 -1
- package/dist/packages/@ember/component/template-only.js +2 -0
- package/dist/packages/@ember/debug/lib/deprecate.js +7 -41
- package/dist/packages/@ember/deprecated-features/index.js +1 -14
- package/dist/packages/@ember/engine/index.js +3 -17
- package/dist/packages/@ember/engine/instance.js +0 -4
- package/dist/packages/@ember/helper/index.js +12 -4
- package/dist/packages/@ember/object/index.js +3 -101
- package/dist/packages/@ember/object/internals.js +0 -1
- package/dist/packages/@ember/object/lib/computed/computed_macros.js +12 -384
- package/dist/packages/@ember/object/lib/computed/reduce_computed_macros.js +9 -360
- package/dist/packages/@ember/polyfills/index.js +1 -6
- package/dist/packages/@ember/polyfills/lib/assign.js +12 -28
- package/dist/packages/@ember/routing/index.js +1 -1
- package/dist/packages/@ember/runloop/index.js +1 -83
- package/dist/packages/@ember/string/index.js +1 -206
- package/dist/packages/@ember/utils/index.js +0 -1
- package/dist/packages/ember/index.js +17 -180
- package/dist/packages/ember/version.js +1 -1
- package/dist/packages/ember-testing/index.js +0 -2
- package/dist/packages/ember-testing/lib/helpers.js +0 -12
- package/dist/packages/ember-testing/lib/setup_for_testing.js +0 -10
- package/docs/data.json +1637 -3659
- package/lib/index.js +14 -59
- package/lib/overrides.js +0 -61
- package/lib/transforms/inject-babel-helpers.js +1 -3
- package/package.json +27 -23
- package/dist/packages/@ember/-internals/console/index.js +0 -190
- package/dist/packages/@ember/-internals/runtime/lib/copy.js +0 -119
- package/dist/packages/@ember/-internals/runtime/lib/ext/function.js +0 -155
- package/dist/packages/@ember/-internals/runtime/lib/mixins/copyable.js +0 -31
- package/dist/packages/@ember/-internals/views/lib/mixins/text_support.js +0 -357
- package/dist/packages/@ember/-internals/views/lib/system/jquery.js +0 -26
- package/dist/packages/@ember/-internals/views/lib/system/jquery_event_deprecation.js +0 -60
- package/dist/packages/@ember/application/deprecations.js +0 -25
- package/dist/packages/@ember/application/globals-resolver.js +0 -434
- package/dist/packages/@ember/application/resolver.js +0 -1
- package/dist/packages/@ember/component/checkbox.js +0 -17
- package/dist/packages/@ember/component/text-area.js +0 -17
- package/dist/packages/@ember/component/text-field.js +0 -17
- package/dist/packages/@ember/polyfills/lib/merge.js +0 -50
- package/dist/packages/@ember/routing/link-component.js +0 -17
- package/dist/packages/ember-testing/lib/events.js +0 -102
- package/dist/packages/ember-testing/lib/helpers/-is-form-control.js +0 -19
- package/dist/packages/ember-testing/lib/helpers/click.js +0 -32
- package/dist/packages/ember-testing/lib/helpers/fill_in.js +0 -47
- package/dist/packages/ember-testing/lib/helpers/find.js +0 -40
- package/dist/packages/ember-testing/lib/helpers/find_with_assert.js +0 -37
- package/dist/packages/ember-testing/lib/helpers/key_event.js +0 -37
- package/dist/packages/ember-testing/lib/helpers/trigger_event.js +0 -61
- package/dist/packages/ember-testing/lib/support.js +0 -57
- package/dist/packages/jquery/index.js +0 -2
|
@@ -1,24 +1,15 @@
|
|
|
1
1
|
import { getOwner } from '@ember/-internals/owner';
|
|
2
|
-
import { assign } from '@ember/polyfills';
|
|
3
2
|
import { assert } from '@ember/debug';
|
|
4
3
|
import { get, set } from '@ember/-internals/metal';
|
|
5
4
|
import { Object as EmberObject } from '@ember/-internals/runtime';
|
|
6
5
|
import { getElementView } from '@ember/-internals/views';
|
|
7
|
-
import { jQuery, jQueryDisabled } from './jquery';
|
|
8
6
|
import ActionManager from './action_manager';
|
|
9
|
-
import addJQueryEventDeprecation from './jquery_event_deprecation';
|
|
10
|
-
import { contains } from './utils';
|
|
11
|
-
import { JQUERY_INTEGRATION, MOUSE_ENTER_LEAVE_MOVE_EVENTS } from '@ember/deprecated-features';
|
|
12
7
|
/**
|
|
13
8
|
@module ember
|
|
14
9
|
*/
|
|
15
10
|
|
|
16
11
|
const ROOT_ELEMENT_CLASS = 'ember-application';
|
|
17
12
|
const ROOT_ELEMENT_SELECTOR = `.${ROOT_ELEMENT_CLASS}`;
|
|
18
|
-
const EVENT_MAP = {
|
|
19
|
-
mouseenter: 'mouseover',
|
|
20
|
-
mouseleave: 'mouseout'
|
|
21
|
-
};
|
|
22
13
|
/**
|
|
23
14
|
`Ember.EventDispatcher` handles delegating browser events to their
|
|
24
15
|
corresponding `Ember.Views.` For example, when you click on a view,
|
|
@@ -59,7 +50,7 @@ export default EmberObject.extend({
|
|
|
59
50
|
@type Object
|
|
60
51
|
@private
|
|
61
52
|
*/
|
|
62
|
-
events:
|
|
53
|
+
events: {
|
|
63
54
|
touchstart: 'touchStart',
|
|
64
55
|
touchmove: 'touchMove',
|
|
65
56
|
touchend: 'touchEnd',
|
|
@@ -84,11 +75,7 @@ export default EmberObject.extend({
|
|
|
84
75
|
dragover: 'dragOver',
|
|
85
76
|
drop: 'drop',
|
|
86
77
|
dragend: 'dragEnd'
|
|
87
|
-
},
|
|
88
|
-
mouseenter: 'mouseEnter',
|
|
89
|
-
mouseleave: 'mouseLeave',
|
|
90
|
-
mousemove: 'mouseMove'
|
|
91
|
-
} : {}),
|
|
78
|
+
},
|
|
92
79
|
|
|
93
80
|
/**
|
|
94
81
|
The root DOM element to which event listeners should be attached. Event
|
|
@@ -108,6 +95,9 @@ export default EmberObject.extend({
|
|
|
108
95
|
|
|
109
96
|
this._eventHandlers = Object.create(null);
|
|
110
97
|
this._didSetup = false;
|
|
98
|
+
this.finalEventNameMapping = null;
|
|
99
|
+
this._sanitizedRootElement = null;
|
|
100
|
+
this.lazyEvents = new Map();
|
|
111
101
|
},
|
|
112
102
|
|
|
113
103
|
/**
|
|
@@ -126,7 +116,11 @@ export default EmberObject.extend({
|
|
|
126
116
|
let environment = owner.lookup('-environment:main');
|
|
127
117
|
return environment.isInteractive;
|
|
128
118
|
})());
|
|
129
|
-
let events = this.
|
|
119
|
+
let events = this.finalEventNameMapping = Object.assign({}, get(this, 'events'), addedEvents);
|
|
120
|
+
this._reverseEventNameMapping = Object.keys(events).reduce((result, key) => Object.assign(result, {
|
|
121
|
+
[events[key]]: key
|
|
122
|
+
}), {});
|
|
123
|
+
let lazyEvents = this.lazyEvents;
|
|
130
124
|
|
|
131
125
|
if (_rootElement !== undefined && _rootElement !== null) {
|
|
132
126
|
set(this, 'rootElement', _rootElement);
|
|
@@ -135,51 +129,61 @@ export default EmberObject.extend({
|
|
|
135
129
|
let rootElementSelector = get(this, 'rootElement');
|
|
136
130
|
let rootElement;
|
|
137
131
|
|
|
138
|
-
if (
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
132
|
+
if (typeof rootElementSelector !== 'string') {
|
|
133
|
+
rootElement = rootElementSelector;
|
|
134
|
+
} else {
|
|
135
|
+
rootElement = document.querySelector(rootElementSelector);
|
|
136
|
+
}
|
|
144
137
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
138
|
+
assert(`You cannot use the same root element (${get(this, 'rootElement') || rootElement.tagName}) multiple times in an Ember.Application`, !rootElement.classList.contains(ROOT_ELEMENT_CLASS));
|
|
139
|
+
assert('You cannot make a new Ember.Application using a root element that is a descendent of an existing Ember.Application', (() => {
|
|
140
|
+
let target = rootElement.parentNode;
|
|
148
141
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
142
|
+
do {
|
|
143
|
+
if (target.classList.contains(ROOT_ELEMENT_CLASS)) {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
153
146
|
|
|
154
|
-
|
|
155
|
-
|
|
147
|
+
target = target.parentNode;
|
|
148
|
+
} while (target && target.nodeType === 1);
|
|
156
149
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
assert(`You cannot use the same root element (${rootElement.selector || rootElement[0].tagName}) multiple times in an Ember.Application`, !rootElement.is(ROOT_ELEMENT_SELECTOR));
|
|
165
|
-
assert('You cannot make a new Ember.Application using a root element that is a descendent of an existing Ember.Application', !rootElement.closest(ROOT_ELEMENT_SELECTOR).length);
|
|
166
|
-
assert('You cannot make a new Ember.Application using a root element that is an ancestor of an existing Ember.Application', !rootElement.find(ROOT_ELEMENT_SELECTOR).length);
|
|
167
|
-
rootElement.addClass(ROOT_ELEMENT_CLASS);
|
|
168
|
-
|
|
169
|
-
if (!rootElement.is(ROOT_ELEMENT_SELECTOR)) {
|
|
170
|
-
throw new TypeError(`Unable to add '${ROOT_ELEMENT_CLASS}' class to root element (${rootElement.selector || rootElement[0].tagName}). Make sure you set rootElement to the body or an element in the body.`);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
150
|
+
return true;
|
|
151
|
+
})());
|
|
152
|
+
assert('You cannot make a new Ember.Application using a root element that is an ancestor of an existing Ember.Application', !rootElement.querySelector(ROOT_ELEMENT_SELECTOR));
|
|
153
|
+
rootElement.classList.add(ROOT_ELEMENT_CLASS);
|
|
154
|
+
assert(`Unable to add '${ROOT_ELEMENT_CLASS}' class to root element (${get(this, 'rootElement') || rootElement.tagName}). Make sure you set rootElement to the body or an element in the body.`, rootElement.classList.contains(ROOT_ELEMENT_CLASS)); // save off the final sanitized root element (for usage in setupHandler)
|
|
155
|
+
|
|
156
|
+
this._sanitizedRootElement = rootElement; // setup event listeners for the non-lazily setup events
|
|
173
157
|
|
|
174
158
|
for (let event in events) {
|
|
175
159
|
if (Object.prototype.hasOwnProperty.call(events, event)) {
|
|
176
|
-
|
|
160
|
+
lazyEvents.set(event, events[event]);
|
|
177
161
|
}
|
|
178
162
|
}
|
|
179
163
|
|
|
180
164
|
this._didSetup = true;
|
|
181
165
|
},
|
|
182
166
|
|
|
167
|
+
/**
|
|
168
|
+
Setup event listeners for the given browser event name
|
|
169
|
+
@private
|
|
170
|
+
@method setupHandlerForBrowserEvent
|
|
171
|
+
@param event the name of the event in the browser
|
|
172
|
+
*/
|
|
173
|
+
setupHandlerForBrowserEvent(event) {
|
|
174
|
+
this.setupHandler(this._sanitizedRootElement, event, this.finalEventNameMapping[event]);
|
|
175
|
+
},
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
Setup event listeners for the given Ember event name (camel case)
|
|
179
|
+
@private
|
|
180
|
+
@method setupHandlerForEmberEvent
|
|
181
|
+
@param eventName
|
|
182
|
+
*/
|
|
183
|
+
setupHandlerForEmberEvent(eventName) {
|
|
184
|
+
this.setupHandler(this._sanitizedRootElement, this._reverseEventNameMapping[eventName], eventName);
|
|
185
|
+
},
|
|
186
|
+
|
|
183
187
|
/**
|
|
184
188
|
Registers an event listener on the rootElement. If the given event is
|
|
185
189
|
triggered, the provided event handler will be triggered on the target view.
|
|
@@ -189,167 +193,92 @@ export default EmberObject.extend({
|
|
|
189
193
|
@private
|
|
190
194
|
@method setupHandler
|
|
191
195
|
@param {Element} rootElement
|
|
192
|
-
@param {String} event the
|
|
196
|
+
@param {String} event the name of the event in the browser
|
|
193
197
|
@param {String} eventName the name of the method to call on the view
|
|
194
198
|
*/
|
|
195
199
|
setupHandler(rootElement, event, eventName) {
|
|
196
|
-
if (eventName === null) {
|
|
197
|
-
return;
|
|
200
|
+
if (eventName === null || !this.lazyEvents.has(event)) {
|
|
201
|
+
return; // nothing to do
|
|
198
202
|
}
|
|
199
203
|
|
|
200
|
-
|
|
201
|
-
let
|
|
202
|
-
|
|
203
|
-
let result = true;
|
|
204
|
-
|
|
205
|
-
if (view) {
|
|
206
|
-
result = view.handleEvent(eventName, event);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
return result;
|
|
210
|
-
};
|
|
204
|
+
let viewHandler = (target, event) => {
|
|
205
|
+
let view = getElementView(target);
|
|
206
|
+
let result = true;
|
|
211
207
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
// attribute it set for each action on a given element. In this case, the
|
|
216
|
-
// attributes need to be read so that a proper set of action handlers can
|
|
217
|
-
// be coalesced.
|
|
218
|
-
|
|
219
|
-
if (actionId === '') {
|
|
220
|
-
let attributes = target.attributes;
|
|
221
|
-
let attributeCount = attributes.length;
|
|
222
|
-
actions = [];
|
|
223
|
-
|
|
224
|
-
for (let i = 0; i < attributeCount; i++) {
|
|
225
|
-
let attr = attributes.item(i);
|
|
226
|
-
let attrName = attr.name;
|
|
227
|
-
|
|
228
|
-
if (attrName.indexOf('data-ember-action-') === 0) {
|
|
229
|
-
actions = actions.concat(ActionManager.registeredActions[attr.value]);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
} // We have to check for actions here since in some cases, jQuery will trigger
|
|
233
|
-
// an event on `removeChild` (i.e. focusout) after we've already torn down the
|
|
234
|
-
// action handlers for the view.
|
|
208
|
+
if (view) {
|
|
209
|
+
result = view.handleEvent(eventName, event);
|
|
210
|
+
}
|
|
235
211
|
|
|
212
|
+
return result;
|
|
213
|
+
};
|
|
236
214
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
215
|
+
let actionHandler = (target, event) => {
|
|
216
|
+
let actionId = target.getAttribute('data-ember-action');
|
|
217
|
+
let actions = ActionManager.registeredActions[actionId]; // In Glimmer2 this attribute is set to an empty string and an additional
|
|
218
|
+
// attribute it set for each action on a given element. In this case, the
|
|
219
|
+
// attributes need to be read so that a proper set of action handlers can
|
|
220
|
+
// be coalesced.
|
|
240
221
|
|
|
241
|
-
|
|
222
|
+
if (actionId === '') {
|
|
223
|
+
let attributes = target.attributes;
|
|
224
|
+
let attributeCount = attributes.length;
|
|
225
|
+
actions = [];
|
|
242
226
|
|
|
243
|
-
for (let
|
|
244
|
-
let
|
|
227
|
+
for (let i = 0; i < attributeCount; i++) {
|
|
228
|
+
let attr = attributes.item(i);
|
|
229
|
+
let attrName = attr.name;
|
|
245
230
|
|
|
246
|
-
if (action
|
|
247
|
-
|
|
248
|
-
result = action.handler(event) && result;
|
|
231
|
+
if (attrName.indexOf('data-ember-action-') === 0) {
|
|
232
|
+
actions = actions.concat(ActionManager.registeredActions[attr.value]);
|
|
249
233
|
}
|
|
250
234
|
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
// Mimics the way this is handled in jQuery,
|
|
255
|
-
// see https://github.com/jquery/jquery/blob/899c56f6ada26821e8af12d9f35fa039100e838e/src/event.js#L666-L700
|
|
235
|
+
} // We have to check for actions here since in some cases, jQuery will trigger
|
|
236
|
+
// an event on `removeChild` (i.e. focusout) after we've already torn down the
|
|
237
|
+
// action handlers for the view.
|
|
256
238
|
|
|
257
239
|
|
|
258
|
-
if (
|
|
259
|
-
|
|
260
|
-
|
|
240
|
+
if (!actions) {
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
261
243
|
|
|
262
|
-
|
|
263
|
-
let fakeEvent = document.createEvent('MouseEvent');
|
|
264
|
-
fakeEvent.initMouseEvent(eventType, false, false, event.view, event.detail, event.screenX, event.screenY, event.clientX, event.clientY, event.ctrlKey, event.altKey, event.shiftKey, event.metaKey, event.button, event.relatedTarget); // fake event.target as we don't dispatch the event
|
|
244
|
+
let result = true;
|
|
265
245
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
enumerable: true
|
|
269
|
-
});
|
|
270
|
-
return fakeEvent;
|
|
271
|
-
};
|
|
246
|
+
for (let index = 0; index < actions.length; index++) {
|
|
247
|
+
let action = actions[index];
|
|
272
248
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
249
|
+
if (action && action.eventName === eventName) {
|
|
250
|
+
// return false if any of the action handlers returns false
|
|
251
|
+
result = action.handler(event) && result;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
276
254
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
if (getElementView(target)) {
|
|
280
|
-
viewHandler(target, createFakeEvent(origEventType, event));
|
|
281
|
-
} else if (target.hasAttribute('data-ember-action')) {
|
|
282
|
-
actionHandler(target, createFakeEvent(origEventType, event));
|
|
283
|
-
} // separate mouseEnter/Leave events are dispatched for each listening element
|
|
284
|
-
// until the element (related) has been reached that the pointing device exited from/to
|
|
255
|
+
return result;
|
|
256
|
+
};
|
|
285
257
|
|
|
258
|
+
let handleEvent = this._eventHandlers[event] = event => {
|
|
259
|
+
let target = event.target;
|
|
286
260
|
|
|
287
|
-
|
|
261
|
+
do {
|
|
262
|
+
if (getElementView(target)) {
|
|
263
|
+
if (viewHandler(target, event) === false) {
|
|
264
|
+
event.preventDefault();
|
|
265
|
+
event.stopPropagation();
|
|
266
|
+
break;
|
|
267
|
+
} else if (event.cancelBubble === true) {
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
270
|
+
} else if (typeof target.hasAttribute === 'function' && target.hasAttribute('data-ember-action')) {
|
|
271
|
+
if (actionHandler(target, event) === false) {
|
|
272
|
+
break;
|
|
288
273
|
}
|
|
289
|
-
};
|
|
290
|
-
|
|
291
|
-
rootElement.addEventListener(mappedEventType, handleMappedEvent);
|
|
292
|
-
} else {
|
|
293
|
-
let handleEvent = this._eventHandlers[event] = event => {
|
|
294
|
-
let target = event.target;
|
|
295
|
-
|
|
296
|
-
do {
|
|
297
|
-
if (getElementView(target)) {
|
|
298
|
-
if (viewHandler(target, event) === false) {
|
|
299
|
-
event.preventDefault();
|
|
300
|
-
event.stopPropagation();
|
|
301
|
-
break;
|
|
302
|
-
} else if (event.cancelBubble === true) {
|
|
303
|
-
break;
|
|
304
|
-
}
|
|
305
|
-
} else if (typeof target.hasAttribute === 'function' && target.hasAttribute('data-ember-action')) {
|
|
306
|
-
if (actionHandler(target, event) === false) {
|
|
307
|
-
break;
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
target = target.parentNode;
|
|
312
|
-
} while (target && target.nodeType === 1);
|
|
313
|
-
};
|
|
314
|
-
|
|
315
|
-
rootElement.addEventListener(event, handleEvent);
|
|
316
|
-
}
|
|
317
|
-
} else {
|
|
318
|
-
rootElement.on(`${event}.ember`, '.ember-view', function (evt) {
|
|
319
|
-
let view = getElementView(this);
|
|
320
|
-
let result = true;
|
|
321
|
-
|
|
322
|
-
if (view) {
|
|
323
|
-
result = view.handleEvent(eventName, addJQueryEventDeprecation(evt));
|
|
324
274
|
}
|
|
325
275
|
|
|
326
|
-
|
|
327
|
-
});
|
|
328
|
-
|
|
329
|
-
let attributes = evt.currentTarget.attributes;
|
|
330
|
-
let handledActions = [];
|
|
331
|
-
evt = addJQueryEventDeprecation(evt);
|
|
332
|
-
|
|
333
|
-
for (let i = 0; i < attributes.length; i++) {
|
|
334
|
-
let attr = attributes.item(i);
|
|
335
|
-
let attrName = attr.name;
|
|
336
|
-
|
|
337
|
-
if (attrName.lastIndexOf('data-ember-action-', 0) !== -1) {
|
|
338
|
-
let action = ActionManager.registeredActions[attr.value]; // We have to check for action here since in some cases, jQuery will trigger
|
|
339
|
-
// an event on `removeChild` (i.e. focusout) after we've already torn down the
|
|
340
|
-
// action handlers for the view.
|
|
276
|
+
target = target.parentNode;
|
|
277
|
+
} while (target && target.nodeType === 1);
|
|
278
|
+
};
|
|
341
279
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
// This effect could cause the `data-ember-action` attribute to shift down and be invoked twice.
|
|
345
|
-
// To avoid this, we keep track of which actions have been handled.
|
|
346
|
-
|
|
347
|
-
handledActions.push(action);
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
});
|
|
352
|
-
}
|
|
280
|
+
rootElement.addEventListener(event, handleEvent);
|
|
281
|
+
this.lazyEvents.delete(event);
|
|
353
282
|
},
|
|
354
283
|
|
|
355
284
|
destroy() {
|
|
@@ -370,12 +299,8 @@ export default EmberObject.extend({
|
|
|
370
299
|
return;
|
|
371
300
|
}
|
|
372
301
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
rootElement.removeEventListener(event, this._eventHandlers[event]);
|
|
376
|
-
}
|
|
377
|
-
} else {
|
|
378
|
-
jQuery(rootElementSelector).off('.ember', '**');
|
|
302
|
+
for (let event in this._eventHandlers) {
|
|
303
|
+
rootElement.removeEventListener(event, this._eventHandlers[event]);
|
|
379
304
|
}
|
|
380
305
|
|
|
381
306
|
rootElement.classList.remove(ROOT_ELEMENT_CLASS);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { assign } from '@ember/polyfills';
|
|
2
1
|
import EmberError from '@ember/error';
|
|
3
2
|
import _default from './default';
|
|
4
|
-
const destroying = assign({}, _default, {
|
|
3
|
+
const destroying = Object.assign({}, _default, {
|
|
5
4
|
appendChild() {
|
|
6
5
|
throw new EmberError("You can't call appendChild on a view being destroyed");
|
|
7
6
|
},
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { assign } from '@ember/polyfills';
|
|
2
1
|
import _default from './default';
|
|
3
2
|
import { join } from '@ember/runloop';
|
|
4
3
|
import { flaggedInstrument } from '@ember/instrumentation';
|
|
5
|
-
const hasElement = assign({}, _default, {
|
|
4
|
+
const hasElement = Object.assign({}, _default, {
|
|
6
5
|
rerender(view) {
|
|
7
6
|
view.renderer.rerender(view);
|
|
8
7
|
},
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { teardownMandatorySetter } from '@ember/-internals/utils';
|
|
2
|
-
import { assign } from '@ember/polyfills';
|
|
3
2
|
import EmberError from '@ember/error';
|
|
4
3
|
import { DEBUG } from '@glimmer/env';
|
|
5
4
|
import hasElement from './has_element';
|
|
6
|
-
const inDOM = assign({}, hasElement, {
|
|
5
|
+
const inDOM = Object.assign({}, hasElement, {
|
|
7
6
|
enter(view) {
|
|
8
7
|
// Register the view for event handling. This hash is used by
|
|
9
8
|
// Ember.EventDispatcher to dispatch incoming events.
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
@module @ember/application
|
|
3
3
|
*/
|
|
4
|
-
import { assign } from '@ember/polyfills';
|
|
5
4
|
import { get, set, computed } from '@ember/-internals/metal';
|
|
6
5
|
import * as environment from '@ember/-internals/browser-environment';
|
|
7
|
-
import { jQuery } from '@ember/-internals/views';
|
|
8
6
|
import EngineInstance from '@ember/engine/instance';
|
|
9
7
|
import { renderSettled } from '@ember/-internals/glimmer';
|
|
10
8
|
/**
|
|
@@ -53,8 +51,7 @@ const ApplicationInstance = EngineInstance.extend({
|
|
|
53
51
|
|
|
54
52
|
/**
|
|
55
53
|
The root DOM element of the Application as an element or a
|
|
56
|
-
|
|
57
|
-
string](http://api.jquery.com/category/selectors/).
|
|
54
|
+
CSS selector.
|
|
58
55
|
@private
|
|
59
56
|
@property {String|DOMElement} rootElement
|
|
60
57
|
*/
|
|
@@ -184,7 +181,7 @@ const ApplicationInstance = EngineInstance.extend({
|
|
|
184
181
|
let dispatcher = this.lookup('event_dispatcher:main');
|
|
185
182
|
let applicationCustomEvents = get(this.application, 'customEvents');
|
|
186
183
|
let instanceCustomEvents = get(this, 'customEvents');
|
|
187
|
-
let customEvents = assign({}, applicationCustomEvents, instanceCustomEvents);
|
|
184
|
+
let customEvents = Object.assign({}, applicationCustomEvents, instanceCustomEvents);
|
|
188
185
|
dispatcher.setup(customEvents, this.rootElement);
|
|
189
186
|
return dispatcher;
|
|
190
187
|
},
|
|
@@ -303,18 +300,6 @@ ApplicationInstance.reopenClass({
|
|
|
303
300
|
|
|
304
301
|
class BootOptions {
|
|
305
302
|
constructor(options = {}) {
|
|
306
|
-
/**
|
|
307
|
-
Provide a specific instance of jQuery. This is useful in conjunction with
|
|
308
|
-
the `document` option, as it allows you to use a copy of `jQuery` that is
|
|
309
|
-
appropriately bound to the foreign `document` (e.g. a jsdom).
|
|
310
|
-
This is highly experimental and support very incomplete at the moment.
|
|
311
|
-
@property jQuery
|
|
312
|
-
@type Object
|
|
313
|
-
@default auto-detected
|
|
314
|
-
@private
|
|
315
|
-
*/
|
|
316
|
-
this.jQuery = jQuery; // This default is overridable below
|
|
317
|
-
|
|
318
303
|
/**
|
|
319
304
|
Interactive mode: whether we need to set up event delegation and invoke
|
|
320
305
|
lifecycle callbacks on Components.
|
|
@@ -323,7 +308,6 @@ class BootOptions {
|
|
|
323
308
|
@default auto-detected
|
|
324
309
|
@private
|
|
325
310
|
*/
|
|
326
|
-
|
|
327
311
|
this.isInteractive = environment.hasDOM; // This default is overridable below
|
|
328
312
|
|
|
329
313
|
/**
|
|
@@ -360,7 +344,6 @@ class BootOptions {
|
|
|
360
344
|
}
|
|
361
345
|
|
|
362
346
|
if (!this.isBrowser) {
|
|
363
|
-
this.jQuery = null;
|
|
364
347
|
this.isInteractive = false;
|
|
365
348
|
this.location = 'none';
|
|
366
349
|
}
|
|
@@ -383,7 +366,6 @@ class BootOptions {
|
|
|
383
366
|
}
|
|
384
367
|
|
|
385
368
|
if (!this.shouldRender) {
|
|
386
|
-
this.jQuery = null;
|
|
387
369
|
this.isInteractive = false;
|
|
388
370
|
}
|
|
389
371
|
/**
|
|
@@ -448,10 +430,6 @@ class BootOptions {
|
|
|
448
430
|
this.location = options.location;
|
|
449
431
|
}
|
|
450
432
|
|
|
451
|
-
if (options.jQuery !== undefined) {
|
|
452
|
-
this.jQuery = options.jQuery;
|
|
453
|
-
}
|
|
454
|
-
|
|
455
433
|
if (options.isInteractive !== undefined) {
|
|
456
434
|
this.isInteractive = Boolean(options.isInteractive);
|
|
457
435
|
}
|
|
@@ -459,7 +437,7 @@ class BootOptions {
|
|
|
459
437
|
|
|
460
438
|
toEnvironment() {
|
|
461
439
|
// Do we really want to assign all of this!?
|
|
462
|
-
let env = assign({}, environment); // For compatibility with existing code
|
|
440
|
+
let env = Object.assign({}, environment); // For compatibility with existing code
|
|
463
441
|
|
|
464
442
|
env.hasDOM = this.isBrowser;
|
|
465
443
|
env.isInteractive = this.isInteractive;
|
|
@@ -10,15 +10,13 @@ import { join, once, run, schedule } from '@ember/runloop';
|
|
|
10
10
|
import { libraries } from '@ember/-internals/metal';
|
|
11
11
|
import { _loaded, runLoadHooks } from './lazy_load';
|
|
12
12
|
import { RSVP } from '@ember/-internals/runtime';
|
|
13
|
-
import { EventDispatcher
|
|
13
|
+
import { EventDispatcher } from '@ember/-internals/views';
|
|
14
14
|
import { Route, Router, HashLocation, HistoryLocation, AutoLocation, NoneLocation, BucketCache } from '@ember/-internals/routing';
|
|
15
15
|
import ApplicationInstance from '../instance';
|
|
16
16
|
import Engine from '@ember/engine';
|
|
17
17
|
import { privatize as P } from '@ember/-internals/container';
|
|
18
18
|
import { setupApplicationRegistry } from '@ember/-internals/glimmer';
|
|
19
19
|
import { RouterService } from '@ember/-internals/routing';
|
|
20
|
-
import { JQUERY_INTEGRATION } from '@ember/deprecated-features';
|
|
21
|
-
let librariesRegistered = false;
|
|
22
20
|
/**
|
|
23
21
|
An instance of `Application` is the starting point for every Ember
|
|
24
22
|
application. It instantiates, initializes and coordinates the
|
|
@@ -112,7 +110,7 @@ let librariesRegistered = false;
|
|
|
112
110
|
});
|
|
113
111
|
```
|
|
114
112
|
|
|
115
|
-
The `rootElement` can be either a DOM element or a
|
|
113
|
+
The `rootElement` can be either a DOM element or a CSS selector
|
|
116
114
|
string. Note that *views appended to the DOM outside the root element will
|
|
117
115
|
not receive events.* If you specify a custom root element, make sure you only
|
|
118
116
|
append views inside it!
|
|
@@ -176,8 +174,7 @@ let librariesRegistered = false;
|
|
|
176
174
|
const Application = Engine.extend({
|
|
177
175
|
/**
|
|
178
176
|
The root DOM element of the Application. This can be specified as an
|
|
179
|
-
element or a
|
|
180
|
-
[jQuery-compatible selector string](http://api.jquery.com/category/selectors/).
|
|
177
|
+
element or a [selector string](https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Selectors#reference_table_of_selectors).
|
|
181
178
|
This is the element that will be passed to the Application's,
|
|
182
179
|
`eventDispatcher`, which sets up the listeners for event delegation. Every
|
|
183
180
|
view in your application should be a child of the element you specify here.
|
|
@@ -316,12 +313,6 @@ const Application = Engine.extend({
|
|
|
316
313
|
// eslint-disable-line no-unused-vars
|
|
317
314
|
this._super(...arguments);
|
|
318
315
|
|
|
319
|
-
if (!this.$) {
|
|
320
|
-
this.$ = jQuery;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
registerLibraries();
|
|
324
|
-
|
|
325
316
|
if (DEBUG) {
|
|
326
317
|
if (ENV.LOG_VERSION) {
|
|
327
318
|
// we only need to see this once per Application#init
|
|
@@ -489,10 +480,10 @@ const Application = Engine.extend({
|
|
|
489
480
|
import Application from '@ember/application';
|
|
490
481
|
let App = Application.create();
|
|
491
482
|
App.deferReadiness();
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
App.token = token;
|
|
483
|
+
fetch('/auth-token')
|
|
484
|
+
.then(response => response.json())
|
|
485
|
+
.then(data => {
|
|
486
|
+
App.token = data.token;
|
|
496
487
|
App.advanceReadiness();
|
|
497
488
|
});
|
|
498
489
|
```
|
|
@@ -839,7 +830,7 @@ const Application = Engine.extend({
|
|
|
839
830
|
in the non-browser environment, the stand-in `document` object only needs to
|
|
840
831
|
implement a limited subset of the full DOM API. The `SimpleDOM` library is known
|
|
841
832
|
to work.
|
|
842
|
-
Since there is no access
|
|
833
|
+
Since there is no DOM access in the non-browser environment, you must also
|
|
843
834
|
specify a DOM `Element` object in the same `document` for the `rootElement` option
|
|
844
835
|
(as opposed to a selector string like `"body"`).
|
|
845
836
|
See the documentation on the `isBrowser`, `document` and `rootElement` properties
|
|
@@ -862,7 +853,6 @@ const Application = Engine.extend({
|
|
|
862
853
|
} else { // node
|
|
863
854
|
application.register('service:network', NodeNetworkService);
|
|
864
855
|
}
|
|
865
|
-
application.inject('route', 'network', 'service:network');
|
|
866
856
|
};
|
|
867
857
|
export default {
|
|
868
858
|
name: 'network-service',
|
|
@@ -871,11 +861,13 @@ const Application = Engine.extend({
|
|
|
871
861
|
```
|
|
872
862
|
```app/routes/post.js
|
|
873
863
|
import Route from '@ember/routing/route';
|
|
864
|
+
import { inject as service } from '@ember/service';
|
|
874
865
|
// An example of how the (hypothetical) service is used in routes.
|
|
875
|
-
export default Route
|
|
876
|
-
|
|
866
|
+
export default class IndexRoute extends Route {
|
|
867
|
+
@service network;
|
|
868
|
+
model(params) {
|
|
877
869
|
return this.network.fetch(`/api/posts/${params.post_id}.json`);
|
|
878
|
-
}
|
|
870
|
+
}
|
|
879
871
|
afterModel(post) {
|
|
880
872
|
if (post.isExternalContent) {
|
|
881
873
|
return this.network.fetch(`/api/external/?url=${post.externalURL}`);
|
|
@@ -883,7 +875,7 @@ const Application = Engine.extend({
|
|
|
883
875
|
return post;
|
|
884
876
|
}
|
|
885
877
|
}
|
|
886
|
-
}
|
|
878
|
+
}
|
|
887
879
|
```
|
|
888
880
|
```javascript
|
|
889
881
|
// Finally, put all the pieces together
|
|
@@ -970,14 +962,4 @@ function commonSetupRegistry(registry) {
|
|
|
970
962
|
registry.register('service:router', RouterService);
|
|
971
963
|
}
|
|
972
964
|
|
|
973
|
-
function registerLibraries() {
|
|
974
|
-
if (!librariesRegistered) {
|
|
975
|
-
librariesRegistered = true;
|
|
976
|
-
|
|
977
|
-
if (JQUERY_INTEGRATION && hasDOM && !jQueryDisabled) {
|
|
978
|
-
libraries.registerCoreLibrary('jQuery', jQuery().jquery);
|
|
979
|
-
}
|
|
980
|
-
}
|
|
981
|
-
}
|
|
982
|
-
|
|
983
965
|
export default Application;
|