ember-source 4.5.0-alpha.4 → 4.5.0-beta.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.
Files changed (126) hide show
  1. package/CHANGELOG.md +13 -4
  2. package/blueprints-js/-addon-import.js +48 -0
  3. package/blueprints-js/acceptance-test/mocha-files/tests/acceptance/__name__-test.js +24 -0
  4. package/blueprints-js/acceptance-test/mocha-rfc-232-files/tests/acceptance/__name__-test.js +13 -0
  5. package/blueprints-js/acceptance-test/qunit-files/tests/acceptance/__name__-test.js +12 -0
  6. package/blueprints-js/acceptance-test/qunit-rfc-232-files/tests/acceptance/__name__-test.js +13 -0
  7. package/blueprints-js/component/files/__root__/__path__/__name__.js +3 -0
  8. package/blueprints-js/component/files/__root__/__templatepath__/__templatename__.hbs +1 -0
  9. package/blueprints-js/component-addon/files/__root__/__path__/__name__.js +1 -0
  10. package/blueprints-js/component-class/files/__root__/__path__/__name__.js +3 -0
  11. package/blueprints-js/component-class-addon/files/__root__/__path__/__name__.js +1 -0
  12. package/blueprints-js/component-test/mocha-0.12-files/__root__/__testType__/__path__/__test__.js +34 -0
  13. package/blueprints-js/component-test/mocha-files/__root__/__testType__/__path__/__test__.js +36 -0
  14. package/blueprints-js/component-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js +38 -0
  15. package/blueprints-js/component-test/qunit-files/__root__/__testType__/__path__/__test__.js +31 -0
  16. package/blueprints-js/component-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js +36 -0
  17. package/blueprints-js/controller/files/__root__/__path__/__name__.js +3 -0
  18. package/blueprints-js/controller-test/mocha-0.12-files/__root__/__testType__/__path__/__test__.js +16 -0
  19. package/blueprints-js/controller-test/mocha-files/__root__/__testType__/__path__/__test__.js +18 -0
  20. package/blueprints-js/controller-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js +13 -0
  21. package/blueprints-js/controller-test/qunit-files/__root__/__testType__/__path__/__test__.js +12 -0
  22. package/blueprints-js/controller-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js +12 -0
  23. package/blueprints-js/helper/files/__root__/__collection__/__name__.js +5 -0
  24. package/blueprints-js/helper/mu-files/__root__/__collection__/__name__.js +7 -0
  25. package/blueprints-js/helper-addon/files/__root__/__path__/__name__.js +1 -0
  26. package/blueprints-js/helper-test/mocha-0.12-files/__root__/__testType__/__collection__/__name__-test.js +26 -0
  27. package/blueprints-js/helper-test/mocha-files/__root__/__testType__/__collection__/__name__-test.js +28 -0
  28. package/blueprints-js/helper-test/mocha-rfc-232-files/__root__/__testType__/__collection__/__name__-test.js +18 -0
  29. package/blueprints-js/helper-test/qunit-files/__root__/__testType__/__collection__/__name__-test.js +15 -0
  30. package/blueprints-js/helper-test/qunit-rfc-232-files/__root__/__testType__/__collection__/__name__-test.js +17 -0
  31. package/blueprints-js/initializer/files/__root__/initializers/__name__.js +5 -0
  32. package/blueprints-js/initializer-addon/files/__root__/__path__/__name__.js +1 -0
  33. package/blueprints-js/initializer-test/mocha-files/__root__/__testType__/__path__/__name__-test.js +28 -0
  34. package/blueprints-js/initializer-test/mocha-rfc-232-files/__root__/__testType__/__path__/__name__-test.js +31 -0
  35. package/blueprints-js/initializer-test/qunit-files/__root__/__testType__/__path__/__name__-test.js +25 -0
  36. package/blueprints-js/initializer-test/qunit-rfc-232-files/__root__/__testType__/__path__/__name__-test.js +37 -0
  37. package/blueprints-js/instance-initializer/files/__root__/instance-initializers/__name__.js +5 -0
  38. package/blueprints-js/instance-initializer-addon/files/__root__/__path__/__name__.js +1 -0
  39. package/blueprints-js/instance-initializer-test/mocha-files/__root__/__testType__/__path__/__name__-test.js +30 -0
  40. package/blueprints-js/instance-initializer-test/mocha-rfc-232-files/__root__/__testType__/__path__/__name__-test.js +32 -0
  41. package/blueprints-js/instance-initializer-test/qunit-files/__root__/__testType__/__path__/__name__-test.js +26 -0
  42. package/blueprints-js/instance-initializer-test/qunit-rfc-232-files/__root__/__testType__/__path__/__name__-test.js +39 -0
  43. package/blueprints-js/mixin/files/__root__/mixins/__name__.js +3 -0
  44. package/blueprints-js/mixin-test/mocha-files/__root__/__testType__/__name__-test.js +13 -0
  45. package/blueprints-js/mixin-test/mocha-rfc-232-files/__root__/__testType__/__name__-test.js +13 -0
  46. package/blueprints-js/mixin-test/qunit-files/__root__/__testType__/__name__-test.js +12 -0
  47. package/blueprints-js/mixin-test/qunit-rfc-232-files/__root__/__testType__/__name__-test.js +12 -0
  48. package/blueprints-js/route/files/__root__/__path__/__name__.js +9 -0
  49. package/blueprints-js/route/files/__root__/__templatepath__/__templatename__.hbs +2 -0
  50. package/blueprints-js/route-addon/files/__root__/__path__/__name__.js +1 -0
  51. package/blueprints-js/route-addon/files/__root__/__templatepath__/__templatename__.js +1 -0
  52. package/blueprints-js/route-test/mocha-0.12-files/__root__/__testType__/__path__/__test__.js +15 -0
  53. package/blueprints-js/route-test/mocha-files/__root__/__testType__/__path__/__test__.js +17 -0
  54. package/blueprints-js/route-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js +12 -0
  55. package/blueprints-js/route-test/qunit-files/__root__/__testType__/__path__/__test__.js +11 -0
  56. package/blueprints-js/route-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js +11 -0
  57. package/blueprints-js/service/files/__root__/__path__/__name__.js +3 -0
  58. package/blueprints-js/service-test/mocha-0.12-files/__root__/__testType__/__path__/__test__.js +16 -0
  59. package/blueprints-js/service-test/mocha-files/__root__/__testType__/__path__/__test__.js +18 -0
  60. package/blueprints-js/service-test/mocha-rfc-232-files/__root__/__testType__/__path__/__test__.js +13 -0
  61. package/blueprints-js/service-test/qunit-files/__root__/__testType__/__path__/__test__.js +12 -0
  62. package/blueprints-js/service-test/qunit-rfc-232-files/__root__/__testType__/__path__/__test__.js +12 -0
  63. package/blueprints-js/template/files/__root__/__path__/__name__.hbs +0 -0
  64. package/blueprints-js/test-framework-detector.js +60 -0
  65. package/blueprints-js/util/files/__root__/utils/__name__.js +3 -0
  66. package/blueprints-js/util-test/mocha-files/__root__/__testType__/__name__-test.js +11 -0
  67. package/blueprints-js/util-test/mocha-rfc-232-files/__root__/__testType__/__name__-test.js +11 -0
  68. package/blueprints-js/util-test/qunit-files/__root__/__testType__/__name__-test.js +10 -0
  69. package/blueprints-js/util-test/qunit-rfc-232-files/__root__/__testType__/__name__-test.js +10 -0
  70. package/build-metadata.json +3 -3
  71. package/dist/ember-template-compiler.js +12 -5
  72. package/dist/ember-template-compiler.map +1 -1
  73. package/dist/ember-testing.js +1 -1
  74. package/dist/ember-testing.map +1 -1
  75. package/dist/ember.debug.js +722 -1001
  76. package/dist/ember.debug.map +1 -1
  77. package/dist/header/license.js +1 -1
  78. package/dist/packages/@ember/-internals/container/index.js +2 -2
  79. package/dist/packages/@ember/-internals/glimmer/index.js +33 -23
  80. package/dist/packages/@ember/-internals/metal/index.js +19 -7
  81. package/dist/packages/@ember/-internals/routing/lib/location/api.js +3 -3
  82. package/dist/packages/@ember/-internals/routing/lib/location/auto_location.js +5 -1
  83. package/dist/packages/@ember/-internals/routing/lib/services/router.js +7 -6
  84. package/dist/packages/@ember/-internals/routing/lib/services/routing.js +9 -6
  85. package/dist/packages/@ember/-internals/routing/lib/system/route.js +6 -9
  86. package/dist/packages/@ember/-internals/routing/lib/system/router.js +4 -2
  87. package/dist/packages/@ember/-internals/routing/lib/utils.js +15 -25
  88. package/dist/packages/@ember/-internals/runtime/lib/compare.js +4 -1
  89. package/dist/packages/@ember/-internals/runtime/lib/mixins/-proxy.js +14 -15
  90. package/dist/packages/@ember/-internals/runtime/lib/mixins/action_handler.js +32 -44
  91. package/dist/packages/@ember/-internals/runtime/lib/mixins/array.js +1 -1
  92. package/dist/packages/@ember/-internals/runtime/lib/mixins/comparable.js +7 -22
  93. package/dist/packages/@ember/-internals/runtime/lib/mixins/container_proxy.js +34 -46
  94. package/dist/packages/@ember/-internals/runtime/lib/mixins/enumerable.js +2 -15
  95. package/dist/packages/@ember/-internals/runtime/lib/mixins/evented.js +13 -57
  96. package/dist/packages/@ember/-internals/runtime/lib/mixins/mutable_enumerable.js +2 -16
  97. package/dist/packages/@ember/-internals/runtime/lib/mixins/observable.js +64 -134
  98. package/dist/packages/@ember/-internals/runtime/lib/mixins/promise_proxy.js +28 -86
  99. package/dist/packages/@ember/-internals/runtime/lib/mixins/registry_proxy.js +59 -61
  100. package/dist/packages/@ember/-internals/runtime/lib/mixins/target_action_support.js +17 -24
  101. package/dist/packages/@ember/-internals/runtime/lib/system/array_proxy.js +59 -85
  102. package/dist/packages/@ember/-internals/runtime/lib/system/object.js +9 -2
  103. package/dist/packages/@ember/-internals/runtime/lib/system/object_proxy.js +3 -77
  104. package/dist/packages/@ember/-internals/utils/index.js +1 -1
  105. package/dist/packages/@ember/-internals/utils/types.js +1 -0
  106. package/dist/packages/@ember/-internals/views/lib/compat/attrs.js +1 -2
  107. package/dist/packages/@ember/-internals/views/lib/component_lookup.js +2 -2
  108. package/dist/packages/@ember/-internals/views/lib/mixins/action_support.js +3 -9
  109. package/dist/packages/@ember/-internals/views/lib/mixins/child_views_support.js +4 -6
  110. package/dist/packages/@ember/-internals/views/lib/mixins/class_names_support.js +13 -18
  111. package/dist/packages/@ember/-internals/views/lib/mixins/view_state_support.js +3 -2
  112. package/dist/packages/@ember/-internals/views/lib/mixins/view_support.js +57 -58
  113. package/dist/packages/@ember/-internals/views/lib/system/event_dispatcher.js +142 -120
  114. package/dist/packages/@ember/-internals/views/lib/system/utils.js +1 -1
  115. package/dist/packages/@ember/-internals/views/lib/views/states/destroying.js +1 -1
  116. package/dist/packages/@ember/-internals/views/lib/views/states/has_element.js +2 -2
  117. package/dist/packages/@ember/-internals/views/lib/views/states/in_dom.js +3 -1
  118. package/dist/packages/@ember/application/instance.js +1 -0
  119. package/dist/packages/@ember/application/lib/application.js +8 -1
  120. package/dist/packages/@ember/canary-features/index.js +2 -2
  121. package/dist/packages/@ember/engine/instance.js +1 -1
  122. package/dist/packages/@ember/engine/lib/engine-parent.js +1 -5
  123. package/dist/packages/@ember/renderer/index.js +28 -0
  124. package/dist/packages/ember/version.js +1 -1
  125. package/docs/data.json +838 -712
  126. package/package.json +4 -3
@@ -22,130 +22,132 @@ const ROOT_ELEMENT_SELECTOR = `.${ROOT_ELEMENT_CLASS}`;
22
22
  @extends Ember.Object
23
23
  */
24
24
 
25
- export default EmberObject.extend({
26
- /**
27
- The set of events names (and associated handler function names) to be setup
28
- and dispatched by the `EventDispatcher`. Modifications to this list can be done
29
- at setup time, generally via the `Application.customEvents` hash.
30
- To add new events to be listened to:
31
- ```javascript
32
- import Application from '@ember/application';
33
- let App = Application.create({
34
- customEvents: {
35
- paste: 'paste'
36
- }
37
- });
38
- ```
39
- To prevent default events from being listened to:
40
- ```javascript
41
- import Application from '@ember/application';
42
- let App = Application.create({
43
- customEvents: {
44
- mouseenter: null,
45
- mouseleave: null
46
- }
47
- });
48
- ```
49
- @property events
50
- @type Object
51
- @private
52
- */
53
- events: {
54
- touchstart: 'touchStart',
55
- touchmove: 'touchMove',
56
- touchend: 'touchEnd',
57
- touchcancel: 'touchCancel',
58
- keydown: 'keyDown',
59
- keyup: 'keyUp',
60
- keypress: 'keyPress',
61
- mousedown: 'mouseDown',
62
- mouseup: 'mouseUp',
63
- contextmenu: 'contextMenu',
64
- click: 'click',
65
- dblclick: 'doubleClick',
66
- focusin: 'focusIn',
67
- focusout: 'focusOut',
68
- submit: 'submit',
69
- input: 'input',
70
- change: 'change',
71
- dragstart: 'dragStart',
72
- drag: 'drag',
73
- dragenter: 'dragEnter',
74
- dragleave: 'dragLeave',
75
- dragover: 'dragOver',
76
- drop: 'drop',
77
- dragend: 'dragEnd'
78
- },
79
-
80
- /**
81
- The root DOM element to which event listeners should be attached. Event
82
- listeners will be attached to the document unless this is overridden.
83
- Can be specified as a DOMElement or a selector string.
84
- The default body is a string since this may be evaluated before document.body
85
- exists in the DOM.
86
- @private
87
- @property rootElement
88
- @type DOMElement
89
- @default 'body'
90
- */
91
- rootElement: 'body',
92
-
93
- init() {
94
- this._super();
95
-
25
+ export default class EventDispatcher extends EmberObject {
26
+ constructor() {
27
+ super(...arguments);
28
+ /**
29
+ The set of events names (and associated handler function names) to be setup
30
+ and dispatched by the `EventDispatcher`. Modifications to this list can be done
31
+ at setup time, generally via the `Application.customEvents` hash.
32
+ To add new events to be listened to:
33
+ ```javascript
34
+ import Application from '@ember/application';
35
+ let App = Application.create({
36
+ customEvents: {
37
+ paste: 'paste'
38
+ }
39
+ });
40
+ ```
41
+ To prevent default events from being listened to:
42
+ ```javascript
43
+ import Application from '@ember/application';
44
+ let App = Application.create({
45
+ customEvents: {
46
+ mouseenter: null,
47
+ mouseleave: null
48
+ }
49
+ });
50
+ ```
51
+ @property events
52
+ @type Object
53
+ @private
54
+ */
55
+
56
+ this.events = {
57
+ touchstart: 'touchStart',
58
+ touchmove: 'touchMove',
59
+ touchend: 'touchEnd',
60
+ touchcancel: 'touchCancel',
61
+ keydown: 'keyDown',
62
+ keyup: 'keyUp',
63
+ keypress: 'keyPress',
64
+ mousedown: 'mouseDown',
65
+ mouseup: 'mouseUp',
66
+ contextmenu: 'contextMenu',
67
+ click: 'click',
68
+ dblclick: 'doubleClick',
69
+ focusin: 'focusIn',
70
+ focusout: 'focusOut',
71
+ submit: 'submit',
72
+ input: 'input',
73
+ change: 'change',
74
+ dragstart: 'dragStart',
75
+ drag: 'drag',
76
+ dragenter: 'dragEnter',
77
+ dragleave: 'dragLeave',
78
+ dragover: 'dragOver',
79
+ drop: 'drop',
80
+ dragend: 'dragEnd'
81
+ };
82
+ /**
83
+ The root DOM element to which event listeners should be attached. Event
84
+ listeners will be attached to the document unless this is overridden.
85
+ Can be specified as a DOMElement or a selector string.
86
+ The default body is a string since this may be evaluated before document.body
87
+ exists in the DOM.
88
+ @private
89
+ @property rootElement
90
+ @type DOMElement
91
+ @default 'body'
92
+ */
93
+
94
+ this.rootElement = 'body';
96
95
  this._eventHandlers = Object.create(null);
97
96
  this._didSetup = false;
98
97
  this.finalEventNameMapping = null;
99
98
  this._sanitizedRootElement = null;
100
99
  this.lazyEvents = new Map();
101
- },
102
-
100
+ this._reverseEventNameMapping = null;
101
+ }
103
102
  /**
104
103
  Sets up event listeners for standard browser events.
105
- This will be called after the browser sends a `DOMContentReady` event. By
104
+ This will be called after the browser sends a `DOMContentReady` event. By
106
105
  default, it will set up all of the listeners on the document body. If you
107
106
  would like to register the listeners on a different element, set the event
108
107
  dispatcher's `root` property.
109
- @private
108
+ @private
110
109
  @method setup
111
110
  @param addedEvents {Object}
112
111
  */
112
+
113
+
113
114
  setup(addedEvents, _rootElement) {
115
+ var _a;
116
+
114
117
  assert('EventDispatcher should never be setup in fastboot mode. Please report this as an Ember bug.', (() => {
115
118
  let owner = getOwner(this);
119
+ assert('[BUG] Missing owner', owner); // SAFETY: This is not guaranteed to be safe, but this is what we expect to be returned.
120
+
116
121
  let environment = owner.lookup('-environment:main');
117
122
  return environment.isInteractive;
118
123
  })());
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
- }), {});
124
+ let events = this.finalEventNameMapping = Object.assign(Object.assign({}, get(this, 'events')), addedEvents);
125
+ this._reverseEventNameMapping = Object.keys(events).reduce((result, key) => {
126
+ let eventName = events[key];
127
+ return eventName ? Object.assign(Object.assign({}, result), {
128
+ [eventName]: key
129
+ }) : result;
130
+ }, {});
123
131
  let lazyEvents = this.lazyEvents;
124
132
 
125
133
  if (_rootElement !== undefined && _rootElement !== null) {
126
134
  set(this, 'rootElement', _rootElement);
127
135
  }
128
136
 
129
- let rootElementSelector = get(this, 'rootElement');
130
- let rootElement;
131
-
132
- if (typeof rootElementSelector !== 'string') {
133
- rootElement = rootElementSelector;
134
- } else {
135
- rootElement = document.querySelector(rootElementSelector);
136
- }
137
-
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));
137
+ let specifiedRootElement = get(this, 'rootElement');
138
+ let rootElement = typeof specifiedRootElement !== 'string' ? specifiedRootElement : document.querySelector(specifiedRootElement);
139
+ assert(`Could not find rootElement (${specifiedRootElement})`, rootElement);
140
+ assert(`You cannot use the same root element (${specifiedRootElement}) multiple times in an Ember.Application`, !rootElement.classList.contains(ROOT_ELEMENT_CLASS));
139
141
  assert('You cannot make a new Ember.Application using a root element that is a descendent of an existing Ember.Application', (() => {
140
142
  let target = rootElement.parentNode;
141
143
 
142
- do {
144
+ while (target instanceof Element) {
143
145
  if (target.classList.contains(ROOT_ELEMENT_CLASS)) {
144
146
  return false;
145
147
  }
146
148
 
147
149
  target = target.parentNode;
148
- } while (target && target.nodeType === 1);
150
+ }
149
151
 
150
152
  return true;
151
153
  })());
@@ -157,55 +159,72 @@ export default EmberObject.extend({
157
159
 
158
160
  for (let event in events) {
159
161
  if (Object.prototype.hasOwnProperty.call(events, event)) {
160
- lazyEvents.set(event, events[event]);
162
+ lazyEvents.set(event, (_a = events[event]) !== null && _a !== void 0 ? _a : null);
161
163
  }
162
164
  }
163
165
 
164
166
  this._didSetup = true;
165
- },
166
-
167
+ }
167
168
  /**
168
169
  Setup event listeners for the given browser event name
169
- @private
170
+ @private
170
171
  @method setupHandlerForBrowserEvent
171
172
  @param event the name of the event in the browser
172
173
  */
174
+
175
+
173
176
  setupHandlerForBrowserEvent(event) {
174
- this.setupHandler(this._sanitizedRootElement, event, this.finalEventNameMapping[event]);
175
- },
177
+ var _a;
176
178
 
179
+ assert('[BUG] Expected finalEventNameMapping to be set', this.finalEventNameMapping);
180
+ assert('[BUG] Expected _santizedRootElement to be set', this._sanitizedRootElement);
181
+ this.setupHandler(this._sanitizedRootElement, event, (_a = this.finalEventNameMapping[event]) !== null && _a !== void 0 ? _a : null);
182
+ }
177
183
  /**
178
184
  Setup event listeners for the given Ember event name (camel case)
179
- @private
185
+ @private
180
186
  @method setupHandlerForEmberEvent
181
187
  @param eventName
182
188
  */
189
+
190
+
183
191
  setupHandlerForEmberEvent(eventName) {
184
- this.setupHandler(this._sanitizedRootElement, this._reverseEventNameMapping[eventName], eventName);
185
- },
192
+ var _a;
193
+
194
+ assert('[BUG] Expected _sanitizedRootElement to be set', this._sanitizedRootElement);
195
+ let event = (_a = this._reverseEventNameMapping) === null || _a === void 0 ? void 0 : _a[eventName];
186
196
 
197
+ if (event) {
198
+ this.setupHandler(this._sanitizedRootElement, event, eventName);
199
+ }
200
+ }
187
201
  /**
188
202
  Registers an event listener on the rootElement. If the given event is
189
203
  triggered, the provided event handler will be triggered on the target view.
190
- If the target view does not implement the event handler, or if the handler
204
+ If the target view does not implement the event handler, or if the handler
191
205
  returns `false`, the parent view will be called. The event will continue to
192
206
  bubble to each successive parent view until it reaches the top.
193
- @private
207
+ @private
194
208
  @method setupHandler
195
209
  @param {Element} rootElement
196
210
  @param {String} event the name of the event in the browser
197
211
  @param {String} eventName the name of the method to call on the view
198
212
  */
213
+
214
+
199
215
  setupHandler(rootElement, event, eventName) {
200
216
  if (eventName === null || !this.lazyEvents.has(event)) {
201
217
  return; // nothing to do
202
218
  }
203
219
 
204
220
  let viewHandler = (target, event) => {
221
+ // SAFETY: SimpleElement is supposed to be a subset of Element so this _should_ be safe.
222
+ // However, the types are more specific in some places which necessitates the `as`.
205
223
  let view = getElementView(target);
206
224
  let result = true;
207
225
 
208
226
  if (view) {
227
+ // SAFETY: As currently written, this is not safe. Though it seems to always be true.
209
228
  result = view.handleEvent(eventName, event);
210
229
  }
211
230
 
@@ -214,30 +233,37 @@ export default EmberObject.extend({
214
233
 
215
234
  let actionHandler = (target, event) => {
216
235
  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
236
+ let actions; // In Glimmer2 this attribute is set to an empty string and an additional
218
237
  // attribute it set for each action on a given element. In this case, the
219
238
  // attributes need to be read so that a proper set of action handlers can
220
239
  // be coalesced.
221
240
 
222
241
  if (actionId === '') {
223
- let attributes = target.attributes;
224
- let attributeCount = attributes.length;
225
242
  actions = [];
226
243
 
227
- for (let i = 0; i < attributeCount; i++) {
228
- let attr = attributes.item(i);
244
+ for (let attr of target.attributes) {
229
245
  let attrName = attr.name;
230
246
 
231
247
  if (attrName.indexOf('data-ember-action-') === 0) {
232
- actions = actions.concat(ActionManager.registeredActions[attr.value]);
248
+ let action = ActionManager.registeredActions[attr.value];
249
+ assert('[BUG] Missing action', action);
250
+ actions.push(action);
233
251
  }
234
252
  }
253
+ } else if (actionId) {
254
+ // FIXME: This branch is never called in tests. Improve tests or remove
255
+ let actionState = ActionManager.registeredActions[actionId];
256
+
257
+ if (actionState) {
258
+ actions = [actionState];
259
+ }
235
260
  } // We have to check for actions here since in some cases, jQuery will trigger
236
261
  // an event on `removeChild` (i.e. focusout) after we've already torn down the
237
262
  // action handlers for the view.
238
263
 
239
264
 
240
265
  if (!actions) {
266
+ // FIXME: This branch is never called in tests. Improve tests or remove
241
267
  return;
242
268
  }
243
269
 
@@ -257,8 +283,11 @@ export default EmberObject.extend({
257
283
 
258
284
  let handleEvent = this._eventHandlers[event] = event => {
259
285
  let target = event.target;
286
+ assert(`[BUG] Received event without an Element target: ${event.type}, ${target}`, target instanceof Element);
260
287
 
261
288
  do {
289
+ // SAFETY: SimpleElement is supposed to be a subset of Element so this _should_ be safe.
290
+ // However, the types are more specific in some places which necessitates the `as`.
262
291
  if (getElementView(target)) {
263
292
  if (viewHandler(target, event) === false) {
264
293
  event.preventDefault();
@@ -274,26 +303,19 @@ export default EmberObject.extend({
274
303
  }
275
304
 
276
305
  target = target.parentNode;
277
- } while (target && target.nodeType === 1);
306
+ } while (target instanceof Element);
278
307
  };
279
308
 
280
309
  rootElement.addEventListener(event, handleEvent);
281
310
  this.lazyEvents.delete(event);
282
- },
311
+ }
283
312
 
284
313
  destroy() {
285
314
  if (this._didSetup === false) {
286
315
  return;
287
316
  }
288
317
 
289
- let rootElementSelector = get(this, 'rootElement');
290
- let rootElement;
291
-
292
- if (rootElementSelector.nodeType) {
293
- rootElement = rootElementSelector;
294
- } else {
295
- rootElement = document.querySelector(rootElementSelector);
296
- }
318
+ let rootElement = this._sanitizedRootElement;
297
319
 
298
320
  if (!rootElement) {
299
321
  return;
@@ -305,10 +327,10 @@ export default EmberObject.extend({
305
327
 
306
328
  rootElement.classList.remove(ROOT_ELEMENT_CLASS);
307
329
  return this._super(...arguments);
308
- },
330
+ }
309
331
 
310
332
  toString() {
311
333
  return '(EventDispatcher)';
312
334
  }
313
335
 
314
- });
336
+ }
@@ -186,7 +186,7 @@ export function getViewBoundingClientRect(view) {
186
186
  @param {String} selector
187
187
  */
188
188
 
189
- export const elMatches = typeof Element !== 'undefined' ? Element.prototype.matches || Element.prototype['matchesSelector'] || Element.prototype['mozMatchesSelector'] || Element.prototype['msMatchesSelector'] || Element.prototype['oMatchesSelector'] || Element.prototype['webkitMatchesSelector'] : undefined;
189
+ export const elMatches = typeof Element !== 'undefined' ? Element.prototype.matches : undefined;
190
190
  export function matches(el, selector) {
191
191
  assert('cannot call `matches` in fastboot mode', elMatches !== undefined);
192
192
  return elMatches.call(el, selector);
@@ -1,6 +1,6 @@
1
1
  import EmberError from '@ember/error';
2
2
  import _default from './default';
3
- const destroying = Object.assign({}, _default, {
3
+ const destroying = Object.assign(Object.assign({}, _default), {
4
4
  appendChild() {
5
5
  throw new EmberError("You can't call appendChild on a view being destroyed");
6
6
  },
@@ -1,9 +1,9 @@
1
1
  import _default from './default';
2
2
  import { join } from '@ember/runloop';
3
3
  import { flaggedInstrument } from '@ember/instrumentation';
4
- const hasElement = Object.assign({}, _default, {
4
+ const hasElement = Object.assign(Object.assign({}, _default), {
5
5
  rerender(view) {
6
- view.renderer.rerender(view);
6
+ view.renderer.rerender();
7
7
  },
8
8
 
9
9
  destroy(view) {
@@ -1,8 +1,9 @@
1
1
  import { teardownMandatorySetter } from '@ember/-internals/utils';
2
+ import { assert } from '@ember/debug';
2
3
  import EmberError from '@ember/error';
3
4
  import { DEBUG } from '@glimmer/env';
4
5
  import hasElement from './has_element';
5
- const inDOM = Object.assign({}, hasElement, {
6
+ const inDOM = Object.assign(Object.assign({}, hasElement), {
6
7
  enter(view) {
7
8
  // Register the view for event handling. This hash is used by
8
9
  // Ember.EventDispatcher to dispatch incoming events.
@@ -10,6 +11,7 @@ const inDOM = Object.assign({}, hasElement, {
10
11
 
11
12
  if (DEBUG) {
12
13
  let elementId = view.elementId;
14
+ assert('[BUG] Expected teardownMandatorySetter to be set in DEBUG mode', teardownMandatorySetter);
13
15
  teardownMandatorySetter(view, 'elementId');
14
16
  Object.defineProperty(view, 'elementId', {
15
17
  configurable: true,
@@ -184,6 +184,7 @@ class ApplicationInstance extends EngineInstance {
184
184
  let applicationCustomEvents = get(this.application, 'customEvents');
185
185
  let instanceCustomEvents = get(this, 'customEvents');
186
186
  let customEvents = Object.assign({}, applicationCustomEvents, instanceCustomEvents);
187
+ assert('[BUG] Tried to set up dispatcher with an invalid root element', this.rootElement === null || typeof this.rootElement === 'string' || this.rootElement instanceof Element);
187
188
  dispatcher.setup(customEvents, this.rootElement);
188
189
  return dispatcher;
189
190
  }
@@ -335,11 +335,18 @@ class Application extends Engine {
335
335
 
336
336
 
337
337
  waitForDOMReady() {
338
- const document = this._document;
338
+ const document = this._document; // SAFETY: Casting as Document should be safe since we're just reading a property.
339
+ // If it's not actually a Document then it will evaluate false which is fine for our
340
+ // purposes.
339
341
 
340
342
  if (document === null || document.readyState !== 'loading') {
341
343
  schedule('actions', this, this.domReady);
342
344
  } else {
345
+ // Ideally we'd just check `document instanceof Document` but currently some tests pass a fake document.
346
+ assert('[BUG] Called waitForDOMReady with an invalid document', function (d) {
347
+ return typeof d.removeEventListener === 'function';
348
+ }(document));
349
+
343
350
  let callback = () => {
344
351
  document.removeEventListener('DOMContentLoaded', callback);
345
352
  run(this, this.domReady);
@@ -11,8 +11,8 @@ import { ENV } from '@ember/-internals/environment';
11
11
  */
12
12
 
13
13
  export const DEFAULT_FEATURES = {
14
- EMBER_LIBRARIES_ISREGISTERED: null,
15
- EMBER_IMPROVED_INSTRUMENTATION: null,
14
+ EMBER_LIBRARIES_ISREGISTERED: false,
15
+ EMBER_IMPROVED_INSTRUMENTATION: false,
16
16
  EMBER_UNIQUE_ID_HELPER: true,
17
17
  EMBER_DEFAULT_HELPER_MANAGER: true
18
18
  };
@@ -6,7 +6,7 @@ import { assert } from '@ember/debug';
6
6
  import EmberError from '@ember/error';
7
7
  import { Registry, privatize as P } from '@ember/-internals/container';
8
8
  import { guidFor } from '@ember/-internals/utils';
9
- import { getEngineParent, setEngineParent } from './lib/engine-parent';
9
+ import { ENGINE_PARENT, getEngineParent, setEngineParent } from './lib/engine-parent';
10
10
  import RegistryProxyMixin from '@ember/-internals/runtime/lib/mixins/registry_proxy';
11
11
  import ContainerProxyMixin from '@ember/-internals/runtime/lib/mixins/container_proxy';
12
12
  import { isFactory } from '@ember/-internals/owner';
@@ -1,8 +1,4 @@
1
- /**
2
- @module @ember/engine
3
- */
4
- import { symbol } from '@ember/-internals/utils';
5
- const ENGINE_PARENT = symbol('ENGINE_PARENT');
1
+ export const ENGINE_PARENT = Symbol('ENGINE_PARENT');
6
2
  /**
7
3
  `getEngineParent` retrieves an engine instance's parent instance.
8
4
 
@@ -0,0 +1,28 @@
1
+ /**
2
+ @module @ember/renderer
3
+ @public
4
+ */
5
+
6
+ /**
7
+ * @class Renderer
8
+ * @public
9
+ */
10
+
11
+ /**
12
+ Returns a promise which will resolve when rendering has completed. In
13
+ this context, rendering is completed when all auto-tracked state that is
14
+ consumed in the template (including any tracked state in models, services,
15
+ etc. that are then used in a template) has been updated in the DOM.
16
+
17
+ For example, in a test you might want to update some tracked state and
18
+ then run some assertions after rendering has completed. You _could_ use
19
+ `await settled()` in that location, but in some contexts you don't want to
20
+ wait for full settledness (which includes test waiters, pending AJAX/fetch,
21
+ run loops, etc) but instead only want to know when that updated value has
22
+ been rendered in the DOM. **THAT** is what `await rerender()` is _perfect_
23
+ for.
24
+ @method renderSettled
25
+ @returns {Promise<void>} a promise which fulfills when rendering has completed
26
+ @public
27
+ */
28
+ export { renderSettled } from '@ember/-internals/glimmer';
@@ -1 +1 @@
1
- export default "4.5.0-alpha.4";
1
+ export default "4.5.0-beta.2";