ember-source 4.0.0-beta.1 → 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 +72 -0
- 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 +383 -961
- package/dist/ember-template-compiler.map +1 -1
- package/dist/ember-testing.js +4 -513
- package/dist/ember-testing.map +1 -1
- package/dist/ember.debug.js +3246 -8084
- package/dist/ember.debug.map +1 -1
- package/dist/header/license.js +1 -1
- package/dist/packages/@ember/-internals/container/index.js +17 -183
- package/dist/packages/@ember/-internals/environment/index.js +0 -27
- package/dist/packages/@ember/-internals/extension-support/lib/container_debug_adapter.js +7 -0
- package/dist/packages/@ember/-internals/glimmer/index.js +4827 -6812
- package/dist/packages/@ember/-internals/metal/index.js +21 -45
- package/dist/packages/@ember/-internals/routing/lib/services/router.js +8 -0
- package/dist/packages/@ember/-internals/routing/lib/services/routing.js +1 -1
- package/dist/packages/@ember/-internals/routing/lib/system/route.js +1 -41
- package/dist/packages/@ember/-internals/routing/lib/system/router.js +22 -91
- package/dist/packages/@ember/-internals/runtime/lib/mixins/array.js +2 -173
- 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 +4 -90
- package/dist/packages/@ember/-internals/utils/index.js +0 -3
- package/dist/packages/@ember/-internals/views/index.js +0 -2
- package/dist/packages/@ember/-internals/views/lib/mixins/view_support.js +4 -4
- package/dist/packages/@ember/-internals/views/lib/system/event_dispatcher.js +22 -72
- package/dist/packages/@ember/application/instance.js +1 -22
- package/dist/packages/@ember/application/lib/application.js +14 -32
- package/dist/packages/@ember/canary-features/index.js +0 -2
- package/dist/packages/@ember/component/index.js +1 -1
- package/dist/packages/@ember/deprecated-features/index.js +0 -4
- package/dist/packages/@ember/engine/index.js +2 -7
- package/dist/packages/@ember/engine/instance.js +0 -4
- package/dist/packages/@ember/object/lib/computed/computed_macros.js +0 -373
- package/dist/packages/@ember/object/lib/computed/reduce_computed_macros.js +0 -351
- package/dist/packages/@ember/routing/index.js +1 -1
- package/dist/packages/ember/index.js +9 -62
- 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 +598 -1901
- package/lib/index.js +13 -51
- package/package.json +18 -18
- package/dist/packages/@ember/-internals/views/lib/mixins/text_support.js +0 -345
- package/dist/packages/@ember/-internals/views/lib/system/jquery.js +0 -26
- 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/routing/link-component.js +0 -17
- package/dist/packages/ember-testing/lib/events.js +0 -101
- 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,101 +0,0 @@
|
|
|
1
|
-
import { run } from '@ember/runloop';
|
|
2
|
-
import isFormControl from './helpers/-is-form-control';
|
|
3
|
-
const DEFAULT_EVENT_OPTIONS = {
|
|
4
|
-
canBubble: true,
|
|
5
|
-
cancelable: true
|
|
6
|
-
};
|
|
7
|
-
const KEYBOARD_EVENT_TYPES = ['keydown', 'keypress', 'keyup'];
|
|
8
|
-
const MOUSE_EVENT_TYPES = ['click', 'mousedown', 'mouseup', 'dblclick', 'mouseenter', 'mouseleave', 'mousemove', 'mouseout', 'mouseover'];
|
|
9
|
-
export function focus(el) {
|
|
10
|
-
if (!el) {
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
if (el.isContentEditable || isFormControl(el)) {
|
|
15
|
-
let type = el.getAttribute('type');
|
|
16
|
-
|
|
17
|
-
if (type !== 'checkbox' && type !== 'radio' && type !== 'hidden') {
|
|
18
|
-
run(null, function () {
|
|
19
|
-
let browserIsNotFocused = document.hasFocus && !document.hasFocus(); // makes `document.activeElement` be `element`. If the browser is focused, it also fires a focus event
|
|
20
|
-
|
|
21
|
-
el.focus(); // Firefox does not trigger the `focusin` event if the window
|
|
22
|
-
// does not have focus. If the document does not have focus then
|
|
23
|
-
// fire `focusin` event as well.
|
|
24
|
-
|
|
25
|
-
if (browserIsNotFocused) {
|
|
26
|
-
// if the browser is not focused the previous `el.focus()` didn't fire an event, so we simulate it
|
|
27
|
-
fireEvent(el, 'focus', {
|
|
28
|
-
bubbles: false
|
|
29
|
-
});
|
|
30
|
-
fireEvent(el, 'focusin');
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
export function fireEvent(element, type, options = {}) {
|
|
37
|
-
if (!element) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
let event;
|
|
42
|
-
|
|
43
|
-
if (KEYBOARD_EVENT_TYPES.indexOf(type) > -1) {
|
|
44
|
-
event = buildKeyboardEvent(type, options);
|
|
45
|
-
} else if (MOUSE_EVENT_TYPES.indexOf(type) > -1) {
|
|
46
|
-
let rect = element.getBoundingClientRect();
|
|
47
|
-
let x = rect.left + 1;
|
|
48
|
-
let y = rect.top + 1;
|
|
49
|
-
let simulatedCoordinates = {
|
|
50
|
-
screenX: x + 5,
|
|
51
|
-
screenY: y + 95,
|
|
52
|
-
clientX: x,
|
|
53
|
-
clientY: y
|
|
54
|
-
};
|
|
55
|
-
event = buildMouseEvent(type, Object.assign(simulatedCoordinates, options));
|
|
56
|
-
} else {
|
|
57
|
-
event = buildBasicEvent(type, options);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
element.dispatchEvent(event);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function buildBasicEvent(type, options = {}) {
|
|
64
|
-
let event = document.createEvent('Events'); // Event.bubbles is read only
|
|
65
|
-
|
|
66
|
-
let bubbles = options.bubbles !== undefined ? options.bubbles : true;
|
|
67
|
-
let cancelable = options.cancelable !== undefined ? options.cancelable : true;
|
|
68
|
-
delete options.bubbles;
|
|
69
|
-
delete options.cancelable;
|
|
70
|
-
event.initEvent(type, bubbles, cancelable);
|
|
71
|
-
Object.assign(event, options);
|
|
72
|
-
return event;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function buildMouseEvent(type, options = {}) {
|
|
76
|
-
let event;
|
|
77
|
-
|
|
78
|
-
try {
|
|
79
|
-
event = document.createEvent('MouseEvents');
|
|
80
|
-
let eventOpts = Object.assign({}, DEFAULT_EVENT_OPTIONS, options);
|
|
81
|
-
event.initMouseEvent(type, eventOpts.canBubble, eventOpts.cancelable, window, eventOpts.detail, eventOpts.screenX, eventOpts.screenY, eventOpts.clientX, eventOpts.clientY, eventOpts.ctrlKey, eventOpts.altKey, eventOpts.shiftKey, eventOpts.metaKey, eventOpts.button, eventOpts.relatedTarget);
|
|
82
|
-
} catch (e) {
|
|
83
|
-
event = buildBasicEvent(type, options);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return event;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function buildKeyboardEvent(type, options = {}) {
|
|
90
|
-
let event;
|
|
91
|
-
|
|
92
|
-
try {
|
|
93
|
-
event = document.createEvent('KeyEvents');
|
|
94
|
-
let eventOpts = Object.assign({}, DEFAULT_EVENT_OPTIONS, options);
|
|
95
|
-
event.initKeyEvent(type, eventOpts.canBubble, eventOpts.cancelable, window, eventOpts.ctrlKey, eventOpts.altKey, eventOpts.shiftKey, eventOpts.metaKey, eventOpts.keyCode, eventOpts.charCode);
|
|
96
|
-
} catch (e) {
|
|
97
|
-
event = buildBasicEvent(type, options);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return event;
|
|
101
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const FORM_CONTROL_TAGS = ['INPUT', 'BUTTON', 'SELECT', 'TEXTAREA'];
|
|
2
|
-
/**
|
|
3
|
-
@private
|
|
4
|
-
@param {Element} element the element to check
|
|
5
|
-
@returns {boolean} `true` when the element is a form control, `false` otherwise
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
export default function isFormControl(element) {
|
|
9
|
-
let {
|
|
10
|
-
tagName,
|
|
11
|
-
type
|
|
12
|
-
} = element;
|
|
13
|
-
|
|
14
|
-
if (type === 'hidden') {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return FORM_CONTROL_TAGS.indexOf(tagName) > -1;
|
|
19
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
@module ember
|
|
3
|
-
*/
|
|
4
|
-
import { focus, fireEvent } from '../events';
|
|
5
|
-
/**
|
|
6
|
-
Clicks an element and triggers any actions triggered by the element's `click`
|
|
7
|
-
event.
|
|
8
|
-
|
|
9
|
-
Example:
|
|
10
|
-
|
|
11
|
-
```javascript
|
|
12
|
-
click('.some-jQuery-selector').then(function() {
|
|
13
|
-
// assert something
|
|
14
|
-
});
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
@method click
|
|
18
|
-
@param {String} selector jQuery selector for finding element on the DOM
|
|
19
|
-
@param {Object} context A DOM Element, Document, or jQuery to use as context
|
|
20
|
-
@return {RSVP.Promise<undefined>}
|
|
21
|
-
@public
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
export default function click(app, selector, context) {
|
|
25
|
-
let $el = app.testHelpers.findWithAssert(selector, context);
|
|
26
|
-
let el = $el[0];
|
|
27
|
-
fireEvent(el, 'mousedown');
|
|
28
|
-
focus(el);
|
|
29
|
-
fireEvent(el, 'mouseup');
|
|
30
|
-
fireEvent(el, 'click');
|
|
31
|
-
return app.testHelpers.wait();
|
|
32
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
@module ember
|
|
3
|
-
*/
|
|
4
|
-
import { focus, fireEvent } from '../events';
|
|
5
|
-
import isFormControl from './-is-form-control';
|
|
6
|
-
/**
|
|
7
|
-
Fills in an input element with some text.
|
|
8
|
-
|
|
9
|
-
Example:
|
|
10
|
-
|
|
11
|
-
```javascript
|
|
12
|
-
fillIn('#email', 'you@example.com').then(function() {
|
|
13
|
-
// assert something
|
|
14
|
-
});
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
@method fillIn
|
|
18
|
-
@param {String} selector jQuery selector finding an input element on the DOM
|
|
19
|
-
to fill text with
|
|
20
|
-
@param {String} text text to place inside the input element
|
|
21
|
-
@return {RSVP.Promise<undefined>}
|
|
22
|
-
@public
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
export default function fillIn(app, selector, contextOrText, text) {
|
|
26
|
-
let $el, el, context;
|
|
27
|
-
|
|
28
|
-
if (text === undefined) {
|
|
29
|
-
text = contextOrText;
|
|
30
|
-
} else {
|
|
31
|
-
context = contextOrText;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
$el = app.testHelpers.findWithAssert(selector, context);
|
|
35
|
-
el = $el[0];
|
|
36
|
-
focus(el);
|
|
37
|
-
|
|
38
|
-
if (isFormControl(el)) {
|
|
39
|
-
el.value = text;
|
|
40
|
-
} else {
|
|
41
|
-
el.innerHTML = text;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
fireEvent(el, 'input');
|
|
45
|
-
fireEvent(el, 'change');
|
|
46
|
-
return app.testHelpers.wait();
|
|
47
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
@module ember
|
|
3
|
-
*/
|
|
4
|
-
import { get } from '@ember/-internals/metal';
|
|
5
|
-
import { assert } from '@ember/debug';
|
|
6
|
-
import { jQueryDisabled } from '@ember/-internals/views';
|
|
7
|
-
/**
|
|
8
|
-
Finds an element in the context of the app's container element. A simple alias
|
|
9
|
-
for `app.$(selector)`.
|
|
10
|
-
|
|
11
|
-
Example:
|
|
12
|
-
|
|
13
|
-
```javascript
|
|
14
|
-
var $el = find('.my-selector');
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
With the `context` param:
|
|
18
|
-
|
|
19
|
-
```javascript
|
|
20
|
-
var $el = find('.my-selector', '.parent-element-class');
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
@method find
|
|
24
|
-
@param {String} selector jQuery selector for element lookup
|
|
25
|
-
@param {String} [context] (optional) jQuery selector that will limit the selector
|
|
26
|
-
argument to find only within the context's children
|
|
27
|
-
@return {Object} DOM element representing the results of the query
|
|
28
|
-
@public
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
export default function find(app, selector, context) {
|
|
32
|
-
if (jQueryDisabled) {
|
|
33
|
-
assert('If jQuery is disabled, please import and use helpers from @ember/test-helpers [https://github.com/emberjs/ember-test-helpers]. Note: `find` is not an available helper.');
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
let $el;
|
|
37
|
-
context = context || get(app, 'rootElement');
|
|
38
|
-
$el = app.$(selector, context);
|
|
39
|
-
return $el;
|
|
40
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
@module ember
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
Like `find`, but throws an error if the element selector returns no results.
|
|
7
|
-
|
|
8
|
-
Example:
|
|
9
|
-
|
|
10
|
-
```javascript
|
|
11
|
-
var $el = findWithAssert('.doesnt-exist'); // throws error
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
With the `context` param:
|
|
15
|
-
|
|
16
|
-
```javascript
|
|
17
|
-
var $el = findWithAssert('.selector-id', '.parent-element-class'); // assert will pass
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
@method findWithAssert
|
|
21
|
-
@param {String} selector jQuery selector string for finding an element within
|
|
22
|
-
the DOM
|
|
23
|
-
@param {String} [context] (optional) jQuery selector that will limit the
|
|
24
|
-
selector argument to find only within the context's children
|
|
25
|
-
@return {Object} jQuery object representing the results of the query
|
|
26
|
-
@throws {Error} throws error if object returned has a length of 0
|
|
27
|
-
@public
|
|
28
|
-
*/
|
|
29
|
-
export default function findWithAssert(app, selector, context) {
|
|
30
|
-
let $el = app.testHelpers.find(selector, context);
|
|
31
|
-
|
|
32
|
-
if ($el.length === 0) {
|
|
33
|
-
throw new Error('Element ' + selector + ' not found.');
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return $el;
|
|
37
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
@module ember
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
Simulates a key event, e.g. `keypress`, `keydown`, `keyup` with the desired keyCode
|
|
7
|
-
Example:
|
|
8
|
-
```javascript
|
|
9
|
-
keyEvent('.some-jQuery-selector', 'keypress', 13).then(function() {
|
|
10
|
-
// assert something
|
|
11
|
-
});
|
|
12
|
-
```
|
|
13
|
-
@method keyEvent
|
|
14
|
-
@param {String} selector jQuery selector for finding element on the DOM
|
|
15
|
-
@param {String} type the type of key event, e.g. `keypress`, `keydown`, `keyup`
|
|
16
|
-
@param {Number} keyCode the keyCode of the simulated key event
|
|
17
|
-
@return {RSVP.Promise<undefined>}
|
|
18
|
-
@since 1.5.0
|
|
19
|
-
@public
|
|
20
|
-
*/
|
|
21
|
-
export default function keyEvent(app, selector, contextOrType, typeOrKeyCode, keyCode) {
|
|
22
|
-
let context, type;
|
|
23
|
-
|
|
24
|
-
if (keyCode === undefined) {
|
|
25
|
-
context = null;
|
|
26
|
-
keyCode = typeOrKeyCode;
|
|
27
|
-
type = contextOrType;
|
|
28
|
-
} else {
|
|
29
|
-
context = contextOrType;
|
|
30
|
-
type = typeOrKeyCode;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return app.testHelpers.triggerEvent(selector, context, type, {
|
|
34
|
-
keyCode,
|
|
35
|
-
which: keyCode
|
|
36
|
-
});
|
|
37
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
@module ember
|
|
3
|
-
*/
|
|
4
|
-
import { fireEvent } from '../events';
|
|
5
|
-
/**
|
|
6
|
-
Triggers the given DOM event on the element identified by the provided selector.
|
|
7
|
-
Example:
|
|
8
|
-
```javascript
|
|
9
|
-
triggerEvent('#some-elem-id', 'blur');
|
|
10
|
-
```
|
|
11
|
-
This is actually used internally by the `keyEvent` helper like so:
|
|
12
|
-
```javascript
|
|
13
|
-
triggerEvent('#some-elem-id', 'keypress', { keyCode: 13 });
|
|
14
|
-
```
|
|
15
|
-
@method triggerEvent
|
|
16
|
-
@param {String} selector jQuery selector for finding element on the DOM
|
|
17
|
-
@param {String} [context] jQuery selector that will limit the selector
|
|
18
|
-
argument to find only within the context's children
|
|
19
|
-
@param {String} type The event type to be triggered.
|
|
20
|
-
@param {Object} [options] The options to be passed to jQuery.Event.
|
|
21
|
-
@return {RSVP.Promise<undefined>}
|
|
22
|
-
@since 1.5.0
|
|
23
|
-
@public
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
export default function triggerEvent(app, selector, contextOrType, typeOrOptions, possibleOptions) {
|
|
27
|
-
let arity = arguments.length;
|
|
28
|
-
let context, type, options;
|
|
29
|
-
|
|
30
|
-
if (arity === 3) {
|
|
31
|
-
// context and options are optional, so this is
|
|
32
|
-
// app, selector, type
|
|
33
|
-
context = null;
|
|
34
|
-
type = contextOrType;
|
|
35
|
-
options = {};
|
|
36
|
-
} else if (arity === 4) {
|
|
37
|
-
// context and options are optional, so this is
|
|
38
|
-
if (typeof typeOrOptions === 'object') {
|
|
39
|
-
// either
|
|
40
|
-
// app, selector, type, options
|
|
41
|
-
context = null;
|
|
42
|
-
type = contextOrType;
|
|
43
|
-
options = typeOrOptions;
|
|
44
|
-
} else {
|
|
45
|
-
// or
|
|
46
|
-
// app, selector, context, type
|
|
47
|
-
context = contextOrType;
|
|
48
|
-
type = typeOrOptions;
|
|
49
|
-
options = {};
|
|
50
|
-
}
|
|
51
|
-
} else {
|
|
52
|
-
context = contextOrType;
|
|
53
|
-
type = typeOrOptions;
|
|
54
|
-
options = possibleOptions;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
let $el = app.testHelpers.findWithAssert(selector, context);
|
|
58
|
-
let el = $el[0];
|
|
59
|
-
fireEvent(el, type, options);
|
|
60
|
-
return app.testHelpers.wait();
|
|
61
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { warn } from '@ember/debug';
|
|
2
|
-
import { jQuery, jQueryDisabled } from '@ember/-internals/views';
|
|
3
|
-
import { hasDOM } from '@ember/-internals/browser-environment';
|
|
4
|
-
/**
|
|
5
|
-
@module ember
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const $ = jQuery;
|
|
9
|
-
/**
|
|
10
|
-
This method creates a checkbox and triggers the click event to fire the
|
|
11
|
-
passed in handler. It is used to correct for a bug in older versions
|
|
12
|
-
of jQuery (e.g 1.8.3).
|
|
13
|
-
|
|
14
|
-
@private
|
|
15
|
-
@method testCheckboxClick
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
function testCheckboxClick(handler) {
|
|
19
|
-
let input = document.createElement('input');
|
|
20
|
-
$(input).attr('type', 'checkbox').css({
|
|
21
|
-
position: 'absolute',
|
|
22
|
-
left: '-1000px',
|
|
23
|
-
top: '-1000px'
|
|
24
|
-
}).appendTo('body').on('click', handler).trigger('click').remove();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (hasDOM && !jQueryDisabled) {
|
|
28
|
-
$(function () {
|
|
29
|
-
/*
|
|
30
|
-
Determine whether a checkbox checked using jQuery's "click" method will have
|
|
31
|
-
the correct value for its checked property.
|
|
32
|
-
If we determine that the current jQuery version exhibits this behavior,
|
|
33
|
-
patch it to work correctly as in the commit for the actual fix:
|
|
34
|
-
https://github.com/jquery/jquery/commit/1fb2f92.
|
|
35
|
-
*/
|
|
36
|
-
testCheckboxClick(function () {
|
|
37
|
-
if (!this.checked && !$.event.special.click) {
|
|
38
|
-
$.event.special.click = {
|
|
39
|
-
// For checkbox, fire native event so checked state will be right
|
|
40
|
-
trigger() {
|
|
41
|
-
if (this.nodeName === 'INPUT' && this.type === 'checkbox' && this.click) {
|
|
42
|
-
this.click();
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
}); // Try again to verify that the patch took effect or blow up.
|
|
50
|
-
|
|
51
|
-
testCheckboxClick(function () {
|
|
52
|
-
warn("clicked checkboxes should be checked! the jQuery patch didn't work", this.checked, {
|
|
53
|
-
id: 'ember-testing.test-checkbox-click'
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
}
|