@testing-library/user-event 14.0.0-alpha.3 → 14.0.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.
@@ -5,6 +5,5 @@ declare global {
5
5
  }
6
6
  }
7
7
  export declare function prepareDocument(document: Document): void;
8
- export { applyNative } from './applyNative';
9
- export { getUIValue, setUIValue } from './value';
10
- export { getUISelection, hasUISelection, setUISelection } from './selection';
8
+ export { getUIValue, setUIValue, startTrackValue, endTrackValue } from './value';
9
+ export { getUISelection, setUISelection } from './selection';
@@ -3,10 +3,10 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "applyNative", {
6
+ Object.defineProperty(exports, "endTrackValue", {
7
7
  enumerable: true,
8
8
  get: function () {
9
- return _applyNative.applyNative;
9
+ return _value.endTrackValue;
10
10
  }
11
11
  });
12
12
  Object.defineProperty(exports, "getUISelection", {
@@ -21,12 +21,6 @@ Object.defineProperty(exports, "getUIValue", {
21
21
  return _value.getUIValue;
22
22
  }
23
23
  });
24
- Object.defineProperty(exports, "hasUISelection", {
25
- enumerable: true,
26
- get: function () {
27
- return _selection.hasUISelection;
28
- }
29
- });
30
24
  exports.prepareDocument = prepareDocument;
31
25
  Object.defineProperty(exports, "setUISelection", {
32
26
  enumerable: true,
@@ -40,6 +34,12 @@ Object.defineProperty(exports, "setUIValue", {
40
34
  return _value.setUIValue;
41
35
  }
42
36
  });
37
+ Object.defineProperty(exports, "startTrackValue", {
38
+ enumerable: true,
39
+ get: function () {
40
+ return _value.startTrackValue;
41
+ }
42
+ });
43
43
 
44
44
  var _dom = require("@testing-library/dom");
45
45
 
@@ -47,8 +47,6 @@ var _selection = require("./selection");
47
47
 
48
48
  var _value = require("./value");
49
49
 
50
- var _applyNative = require("./applyNative");
51
-
52
50
  const isPrepared = Symbol('Node prepared with document state workarounds');
53
51
 
54
52
  function prepareDocument(document) {
@@ -1,5 +1,15 @@
1
1
  declare type anyFunc = (...a: any[]) => any;
2
2
  declare type Params<Prop> = Prop extends anyFunc ? Parameters<Prop> : [Prop];
3
3
  declare type ImplReturn<Prop> = Prop extends anyFunc ? Parameters<Prop> : Prop;
4
- export declare function prepareInterceptor<ElementType extends Element, PropName extends keyof ElementType>(element: ElementType, propName: PropName, interceptorImpl: (this: ElementType, ...args: Params<ElementType[PropName]>) => ImplReturn<ElementType[PropName]>): void;
4
+ export declare function prepareInterceptor<ElementType extends Node, PropName extends keyof ElementType>(element: ElementType, propName: PropName, interceptorImpl: (this: ElementType, ...args: Params<ElementType[PropName]>) => {
5
+ /**
6
+ * React tracks the changes on element properties.
7
+ * This workaround tries to alter the DOM element without React noticing,
8
+ * so that it later picks up the change.
9
+ *
10
+ * @see https://github.com/facebook/react/blob/148f8e497c7d37a3c7ab99f01dec2692427272b1/packages/react-dom/src/client/inputValueTracking.js#L51-L104
11
+ */
12
+ applyNative?: boolean;
13
+ realArgs?: ImplReturn<ElementType[PropName]>;
14
+ }): void;
5
15
  export {};
@@ -8,16 +8,19 @@ const Interceptor = Symbol('Interceptor for programmatical calls');
8
8
 
9
9
  function prepareInterceptor(element, propName, interceptorImpl) {
10
10
  const prototypeDescriptor = Object.getOwnPropertyDescriptor(element.constructor.prototype, propName);
11
+ const objectDescriptor = Object.getOwnPropertyDescriptor(element, propName);
11
12
  const target = prototypeDescriptor != null && prototypeDescriptor.set ? 'set' : 'value';
12
13
 
13
14
  if (typeof (prototypeDescriptor == null ? void 0 : prototypeDescriptor[target]) !== 'function' || prototypeDescriptor[target][Interceptor]) {
14
15
  return;
15
16
  }
16
17
 
17
- const realFunc = prototypeDescriptor[target];
18
-
19
18
  function intercept(...args) {
20
- const realArgs = interceptorImpl.call(this, ...args);
19
+ const {
20
+ applyNative = true,
21
+ realArgs
22
+ } = interceptorImpl.call(this, ...args);
23
+ const realFunc = (!applyNative && objectDescriptor || prototypeDescriptor)[target];
21
24
 
22
25
  if (target === 'set') {
23
26
  realFunc.call(this, realArgs);
@@ -28,7 +31,7 @@ function prepareInterceptor(element, propName, interceptorImpl) {
28
31
 
29
32
  ;
30
33
  intercept[Interceptor] = Interceptor;
31
- Object.defineProperty(element.constructor.prototype, propName, { ...prototypeDescriptor,
34
+ Object.defineProperty(element, propName, { ...(objectDescriptor != null ? objectDescriptor : prototypeDescriptor),
32
35
  [target]: intercept
33
36
  });
34
37
  }
@@ -14,5 +14,4 @@ export declare function getUISelection(element: HTMLInputElement | HTMLTextAreaE
14
14
  selectionEnd: number | null;
15
15
  };
16
16
  export declare function clearUISelection(element: HTMLInputElement | HTMLTextAreaElement): void;
17
- export declare function hasUISelection(element: HTMLInputElement | HTMLTextAreaElement): boolean;
18
17
  export {};
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.clearUISelection = clearUISelection;
7
7
  exports.getUISelection = getUISelection;
8
- exports.hasUISelection = hasUISelection;
9
8
  exports.prepareSelectionInterceptor = prepareSelectionInterceptor;
10
9
  exports.setUISelection = setUISelection;
11
10
 
@@ -19,7 +18,9 @@ function setSelectionInterceptor(start, end, direction = 'none') {
19
18
  start: start.valueOf(),
20
19
  end: Number(end)
21
20
  } : undefined;
22
- return [Number(start), end, direction];
21
+ return {
22
+ realArgs: [Number(start), end, direction]
23
+ };
23
24
  }
24
25
 
25
26
  function prepareSelectionInterceptor(element) {
@@ -60,8 +61,4 @@ function getUISelection(element) {
60
61
 
61
62
  function clearUISelection(element) {
62
63
  element[UISelection] = undefined;
63
- }
64
-
65
- function hasUISelection(element) {
66
- return Boolean(element[UISelection]);
67
64
  }
@@ -1,9 +1,11 @@
1
1
  declare const UIValue: unique symbol;
2
2
  declare const InitialValue: unique symbol;
3
+ declare const TrackChanges: unique symbol;
3
4
  declare global {
4
5
  interface Element {
5
6
  [UIValue]?: string;
6
7
  [InitialValue]?: string;
8
+ [TrackChanges]?: string[];
7
9
  }
8
10
  }
9
11
  export declare function prepareValueInterceptor(element: HTMLInputElement): void;
@@ -11,4 +13,6 @@ export declare function setUIValue(element: HTMLInputElement | HTMLTextAreaEleme
11
13
  export declare function getUIValue(element: HTMLInputElement | HTMLTextAreaElement): string | undefined;
12
14
  export declare function setInitialValue(element: HTMLInputElement | HTMLTextAreaElement): void;
13
15
  export declare function getInitialValue(element: HTMLInputElement | HTMLTextAreaElement): string | undefined;
16
+ export declare function startTrackValue(element: HTMLInputElement | HTMLTextAreaElement): void;
17
+ export declare function endTrackValue(element: HTMLInputElement | HTMLTextAreaElement): string[] | undefined;
14
18
  export {};
@@ -3,13 +3,13 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.endTrackValue = endTrackValue;
6
7
  exports.getInitialValue = getInitialValue;
7
8
  exports.getUIValue = getUIValue;
8
9
  exports.prepareValueInterceptor = prepareValueInterceptor;
9
10
  exports.setInitialValue = setInitialValue;
10
11
  exports.setUIValue = setUIValue;
11
-
12
- var _applyNative = require("./applyNative");
12
+ exports.startTrackValue = startTrackValue;
13
13
 
14
14
  var _interceptor = require("./interceptor");
15
15
 
@@ -17,19 +17,24 @@ var _selection = require("./selection");
17
17
 
18
18
  const UIValue = Symbol('Displayed value in UI');
19
19
  const InitialValue = Symbol('Initial value to compare on blur');
20
+ const TrackChanges = Symbol('Track programmatic changes for React workaround');
20
21
 
21
22
  function valueInterceptor(v) {
22
23
  const isUI = typeof v === 'object' && v[UIValue];
23
24
  this[UIValue] = isUI ? String(v) : undefined;
24
25
 
25
26
  if (!isUI) {
27
+ trackValue(this, String(v));
26
28
  this[InitialValue] = String(v); // Programmatically setting the value property
27
29
  // moves the cursor to the end of the input.
28
30
 
29
31
  (0, _selection.clearUISelection)(this);
30
32
  }
31
33
 
32
- return String(v);
34
+ return {
35
+ applyNative: !!isUI,
36
+ realArgs: String(v)
37
+ };
33
38
  }
34
39
 
35
40
  function prepareValueInterceptor(element) {
@@ -37,10 +42,10 @@ function prepareValueInterceptor(element) {
37
42
  }
38
43
 
39
44
  function setUIValue(element, value) {
40
- (0, _applyNative.applyNative)(element, 'value', {
45
+ element.value = {
41
46
  [UIValue]: UIValue,
42
47
  toString: () => value
43
- });
48
+ };
44
49
  }
45
50
 
46
51
  function getUIValue(element) {
@@ -53,4 +58,20 @@ function setInitialValue(element) {
53
58
 
54
59
  function getInitialValue(element) {
55
60
  return element[InitialValue];
61
+ }
62
+
63
+ function startTrackValue(element) {
64
+ element[TrackChanges] = [];
65
+ }
66
+
67
+ function trackValue(element, v) {
68
+ var _element$TrackChanges;
69
+
70
+ (_element$TrackChanges = element[TrackChanges]) == null ? void 0 : _element$TrackChanges.push(v);
71
+ }
72
+
73
+ function endTrackValue(element) {
74
+ const tracked = element[TrackChanges];
75
+ element[TrackChanges] = undefined;
76
+ return tracked;
56
77
  }
@@ -79,6 +79,10 @@ const defaultKeyMap = [// alphanumeric keys
79
79
  key: 'OS',
80
80
  location: _types.DOM_KEY_LOCATION.RIGHT,
81
81
  keyCode: 91
82
+ }, {
83
+ code: 'Tab',
84
+ key: 'Tab',
85
+ keyCode: 9
82
86
  }, {
83
87
  code: 'CapsLock',
84
88
  key: 'CapsLock',
@@ -7,6 +7,8 @@ exports.preKeyupBehavior = exports.preKeydownBehavior = exports.postKeyupBehavio
7
7
 
8
8
  var _dom = require("@testing-library/dom");
9
9
 
10
+ var _document = require("../../document");
11
+
10
12
  var _utils = require("../../utils");
11
13
 
12
14
  var _getEventProps = require("../getEventProps");
@@ -65,6 +67,21 @@ const keydownBehavior = [{
65
67
  }
66
68
  });
67
69
  }
70
+ }, {
71
+ matches: keyDef => keyDef.key === 'Tab',
72
+ handle: (keyDef, element, options, state) => {
73
+ const dest = (0, _utils.getTabDestination)(element, state.modifiers.shift, element.ownerDocument);
74
+
75
+ if (dest === element.ownerDocument.body) {
76
+ (0, _utils.blur)(element);
77
+ } else {
78
+ (0, _utils.focus)(dest);
79
+
80
+ if ((0, _utils.isElementType)(dest, ['input', 'textarea'])) {
81
+ (0, _document.setUISelection)(dest, 0, dest.value.length);
82
+ }
83
+ }
84
+ }
68
85
  }];
69
86
  exports.keydownBehavior = keydownBehavior;
70
87
  const keypressBehavior = [{
package/dist/tab.js CHANGED
@@ -9,16 +9,6 @@ var _dom = require("@testing-library/dom");
9
9
 
10
10
  var _utils = require("./utils");
11
11
 
12
- function getNextElement(currentIndex, shift, elements, focusTrap) {
13
- if ((0, _utils.isDocument)(focusTrap) && (currentIndex === 0 && shift || currentIndex === elements.length - 1 && !shift)) {
14
- return focusTrap.body;
15
- }
16
-
17
- const nextIndex = shift ? currentIndex - 1 : currentIndex + 1;
18
- const defaultIndex = shift ? elements.length - 1 : 0;
19
- return elements[nextIndex] || elements[defaultIndex];
20
- }
21
-
22
12
  function tab({
23
13
  shift = false,
24
14
  focusTrap
@@ -26,71 +16,20 @@ function tab({
26
16
  var _focusTrap$ownerDocum, _focusTrap;
27
17
 
28
18
  const doc = (_focusTrap$ownerDocum = (_focusTrap = focusTrap) == null ? void 0 : _focusTrap.ownerDocument) != null ? _focusTrap$ownerDocum : document;
29
- const previousElement = (0, _utils.getActiveElement)(doc);
19
+ const previousElement = (0, _utils.getActiveElement)(doc); // Never the case in our test environment
20
+ // Only happens if the activeElement is inside a shadowRoot that is not part of `doc`.
21
+
22
+ /* istanbul ignore next */
23
+
24
+ if (!previousElement) {
25
+ return;
26
+ }
30
27
 
31
28
  if (!focusTrap) {
32
29
  focusTrap = doc;
33
30
  }
34
31
 
35
- const focusableElements = focusTrap.querySelectorAll(_utils.FOCUSABLE_SELECTOR);
36
- const enabledElements = Array.from(focusableElements).filter(el => el === previousElement || el.getAttribute('tabindex') !== '-1' && !(0, _utils.isDisabled)(el) && // Hidden elements are not tabable
37
- (0, _utils.isVisible)(el));
38
- if (enabledElements.length === 0) return;
39
- const orderedElements = enabledElements.map((el, idx) => ({
40
- el,
41
- idx
42
- })).sort((a, b) => {
43
- // tabindex has no effect if the active element has tabindex="-1"
44
- if (previousElement && previousElement.getAttribute('tabindex') === '-1') {
45
- return a.idx - b.idx;
46
- }
47
-
48
- const tabIndexA = Number(a.el.getAttribute('tabindex'));
49
- const tabIndexB = Number(b.el.getAttribute('tabindex'));
50
- const diff = tabIndexA - tabIndexB;
51
- return diff === 0 ? a.idx - b.idx : diff;
52
- }).map(({
53
- el
54
- }) => el); // TODO: verify/remove type casts
55
-
56
- const checkedRadio = {};
57
- let prunedElements = [];
58
- orderedElements.forEach(currentElement => {
59
- // For radio groups keep only the active radio
60
- // If there is no active radio, keep only the checked radio
61
- // If there is no checked radio, treat like everything else
62
- const el = currentElement;
63
-
64
- if (el.type === 'radio' && el.name) {
65
- // If the active element is part of the group, add only that
66
- const prev = previousElement;
67
-
68
- if (prev && prev.type === el.type && prev.name === el.name) {
69
- if (el === prev) {
70
- prunedElements.push(el);
71
- }
72
-
73
- return;
74
- } // If we stumble upon a checked radio, remove the others
75
-
76
-
77
- if (el.checked) {
78
- prunedElements = prunedElements.filter(e => e.type !== el.type || e.name !== el.name);
79
- prunedElements.push(el);
80
- checkedRadio[el.name] = el;
81
- return;
82
- } // If we already found the checked one, skip
83
-
84
-
85
- if (typeof checkedRadio[el.name] !== 'undefined') {
86
- return;
87
- }
88
- }
89
-
90
- prunedElements.push(el);
91
- });
92
- const index = prunedElements.findIndex(el => el === previousElement);
93
- const nextElement = getNextElement(index, shift, prunedElements, focusTrap);
32
+ const nextElement = (0, _utils.getTabDestination)(previousElement, shift, focusTrap);
94
33
  const shiftKeyInit = {
95
34
  key: 'Shift',
96
35
  keyCode: 16,
@@ -101,25 +40,16 @@ function tab({
101
40
  keyCode: 9,
102
41
  shiftKey: shift
103
42
  };
104
- let continueToTab = true; // not sure how to make it so there's no previous element...
105
- // istanbul ignore else
106
-
107
- if (previousElement) {
108
- // preventDefault on the shift key makes no difference
109
- if (shift) _dom.fireEvent.keyDown(previousElement, { ...shiftKeyInit
110
- });
111
- continueToTab = _dom.fireEvent.keyDown(previousElement, { ...tabKeyInit
112
- });
113
- }
114
-
115
- const keyUpTarget = !continueToTab && previousElement ? previousElement : nextElement;
43
+ let continueToTab = true;
44
+ if (shift) _dom.fireEvent.keyDown(previousElement, { ...shiftKeyInit
45
+ });
46
+ continueToTab = _dom.fireEvent.keyDown(previousElement, { ...tabKeyInit
47
+ });
48
+ const keyUpTarget = continueToTab ? nextElement : previousElement;
116
49
 
117
50
  if (continueToTab) {
118
51
  if (nextElement === doc.body) {
119
- /* istanbul ignore else */
120
- if (previousElement) {
121
- (0, _utils.blur)(previousElement);
122
- }
52
+ (0, _utils.blur)(previousElement);
123
53
  } else {
124
54
  (0, _utils.focus)(nextElement);
125
55
  }
@@ -133,9 +63,4 @@ function tab({
133
63
  shiftKey: false
134
64
  });
135
65
  }
136
- }
137
- /*
138
- eslint
139
- complexity: "off",
140
- max-statements: "off",
141
- */
66
+ }
@@ -20,36 +20,40 @@ function fireInputEvent(element, {
20
20
  newSelectionStart,
21
21
  eventOverrides
22
22
  }) {
23
- // apply the changes before firing the input event, so that input handlers can access the altered dom and selection
23
+ const oldValue = element.value; // apply the changes before firing the input event, so that input handlers can access the altered dom and selection
24
+
24
25
  if ((0, _isContentEditable.isContentEditable)(element)) {
25
- (0, _document.applyNative)(element, 'textContent', newValue);
26
- } else
26
+ element.textContent = newValue;
27
+ } else {
28
+ // The pre-commit hooks keeps changing this
29
+ // See https://github.com/kentcdodds/kcd-scripts/issues/218
30
+
27
31
  /* istanbul ignore else */
32
+ // eslint-disable-next-line no-lonely-if
28
33
  if ((0, _isElementType.isElementType)(element, ['input', 'textarea'])) {
29
34
  (0, _document.setUIValue)(element, newValue);
30
35
  } else {
31
36
  // TODO: properly type guard
32
37
  throw new Error('Invalid Element');
33
38
  }
39
+ }
34
40
 
35
- setSelectionRangeAfterInput(element, newSelectionStart);
41
+ (0, _selectionRange.setSelectionRange)(element, newSelectionStart, newSelectionStart); // When the input event happens in the browser, React executes all event handlers
42
+ // and if they change state of a controlled value, nothing happens.
43
+ // But when we trigger the event handlers in test environment,
44
+ // the changes are rolled back by React before the state update is applied.
45
+ // Then the updated state is applied which results in a resetted cursor.
46
+ // There is probably a better way to work around if we figure out
47
+ // why the batched update is executed differently in our test environment.
48
+
49
+ (0, _document.startTrackValue)(element);
36
50
 
37
51
  _dom.fireEvent.input(element, { ...eventOverrides
38
52
  });
39
53
 
40
- setSelectionRangeAfterInputHandler(element, newSelectionStart);
41
- }
42
-
43
- function setSelectionRangeAfterInput(element, newSelectionStart) {
44
- (0, _selectionRange.setSelectionRange)(element, newSelectionStart, newSelectionStart);
45
- }
54
+ const tracked = (0, _document.endTrackValue)(element);
46
55
 
47
- function setSelectionRangeAfterInputHandler(element, newSelectionStart) {
48
- // On controlled inputs the selection changes without a call to
49
- // either the `value` setter or the `setSelectionRange` method.
50
- // So if our tracked position for UI still exists and derives from a valid selectionStart,
51
- // the cursor was moved due to an input being controlled.
52
- if ((0, _isElementType.isElementType)(element, ['input', 'textarea']) && typeof element.selectionStart === 'number' && element.selectionStart !== newSelectionStart && (0, _document.hasUISelection)(element)) {
56
+ if ((tracked == null ? void 0 : tracked.length) === 2 && tracked[0] === oldValue && tracked[1] === newValue) {
53
57
  (0, _selectionRange.setSelectionRange)(element, newSelectionStart, newSelectionStart);
54
58
  }
55
59
  }
@@ -0,0 +1 @@
1
+ export declare function getTabDestination(activeElement: Element, shift: boolean, focusTrap: Document | Element): Element;
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getTabDestination = getTabDestination;
7
+
8
+ var _isDisabled = require("../misc/isDisabled");
9
+
10
+ var _isDocument = require("../misc/isDocument");
11
+
12
+ var _isElementType = require("../misc/isElementType");
13
+
14
+ var _isVisible = require("../misc/isVisible");
15
+
16
+ var _selector = require("./selector");
17
+
18
+ function getTabDestination(activeElement, shift, focusTrap) {
19
+ const focusableElements = focusTrap.querySelectorAll(_selector.FOCUSABLE_SELECTOR);
20
+ const enabledElements = Array.from(focusableElements).filter(el => el === activeElement || el.getAttribute('tabindex') !== '-1' && !(0, _isDisabled.isDisabled)(el) && // Hidden elements are not tabable
21
+ (0, _isVisible.isVisible)(el));
22
+
23
+ if (activeElement.getAttribute('tabindex') !== '-1') {
24
+ // tabindex has no effect if the active element has tabindex="-1"
25
+ enabledElements.sort((a, b) => Number(a.getAttribute('tabindex')) - Number(b.getAttribute('tabindex')));
26
+ }
27
+
28
+ const checkedRadio = {};
29
+ let prunedElements = (0, _isDocument.isDocument)(focusTrap) ? [focusTrap.body] : [];
30
+ const activeRadioGroup = (0, _isElementType.isElementType)(activeElement, 'input', {
31
+ type: 'radio'
32
+ }) ? activeElement.name : undefined;
33
+ enabledElements.forEach(currentElement => {
34
+ const el = currentElement; // For radio groups keep only the active radio
35
+ // If there is no active radio, keep only the checked radio
36
+ // If there is no checked radio, treat like everything else
37
+
38
+ if ((0, _isElementType.isElementType)(el, 'input', {
39
+ type: 'radio'
40
+ }) && el.name) {
41
+ // If the active element is part of the group, add only that
42
+ if (el === activeElement) {
43
+ prunedElements.push(el);
44
+ return;
45
+ } else if (el.name === activeRadioGroup) {
46
+ return;
47
+ } // If we stumble upon a checked radio, remove the others
48
+
49
+
50
+ if (el.checked) {
51
+ prunedElements = prunedElements.filter(e => !(0, _isElementType.isElementType)(e, 'input', {
52
+ type: 'radio',
53
+ name: el.name
54
+ }));
55
+ prunedElements.push(el);
56
+ checkedRadio[el.name] = el;
57
+ return;
58
+ } // If we already found the checked one, skip
59
+
60
+
61
+ if (typeof checkedRadio[el.name] !== 'undefined') {
62
+ return;
63
+ }
64
+ }
65
+
66
+ prunedElements.push(el);
67
+ });
68
+ const currentIndex = prunedElements.findIndex(el => el === activeElement);
69
+ const nextIndex = shift ? currentIndex - 1 : currentIndex + 1;
70
+ const defaultIndex = shift ? prunedElements.length - 1 : 0;
71
+ return prunedElements[nextIndex] || prunedElements[defaultIndex];
72
+ }
@@ -13,6 +13,7 @@ export * from './edit/selectionRange';
13
13
  export * from './focus/blur';
14
14
  export * from './focus/focus';
15
15
  export * from './focus/getActiveElement';
16
+ export * from './focus/getTabDestination';
16
17
  export * from './focus/isFocusable';
17
18
  export * from './focus/selector';
18
19
  export * from './keyDef/readNextDescriptor';
@@ -199,6 +199,19 @@ Object.keys(_getActiveElement).forEach(function (key) {
199
199
  });
200
200
  });
201
201
 
202
+ var _getTabDestination = require("./focus/getTabDestination");
203
+
204
+ Object.keys(_getTabDestination).forEach(function (key) {
205
+ if (key === "default" || key === "__esModule") return;
206
+ if (key in exports && exports[key] === _getTabDestination[key]) return;
207
+ Object.defineProperty(exports, key, {
208
+ enumerable: true,
209
+ get: function () {
210
+ return _getTabDestination[key];
211
+ }
212
+ });
213
+ });
214
+
202
215
  var _isFocusable = require("./focus/isFocusable");
203
216
 
204
217
  Object.keys(_isFocusable).forEach(function (key) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testing-library/user-event",
3
- "version": "14.0.0-alpha.3",
3
+ "version": "14.0.0-alpha.4",
4
4
  "description": "Fire events the same way the user does",
5
5
  "main": "dist/index.js",
6
6
  "keywords": [
@@ -1,8 +0,0 @@
1
- /**
2
- * React tracks the changes on element properties.
3
- * This workaround tries to alter the DOM element without React noticing,
4
- * so that it later picks up the change.
5
- *
6
- * @see https://github.com/facebook/react/blob/148f8e497c7d37a3c7ab99f01dec2692427272b1/packages/react-dom/src/client/inputValueTracking.js#L51-L104
7
- */
8
- export declare function applyNative<T extends Element, P extends keyof T>(element: T, propName: P, propValue: T[P]): void;
@@ -1,28 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.applyNative = applyNative;
7
-
8
- /**
9
- * React tracks the changes on element properties.
10
- * This workaround tries to alter the DOM element without React noticing,
11
- * so that it later picks up the change.
12
- *
13
- * @see https://github.com/facebook/react/blob/148f8e497c7d37a3c7ab99f01dec2692427272b1/packages/react-dom/src/client/inputValueTracking.js#L51-L104
14
- */
15
- function applyNative(element, propName, propValue) {
16
- const descriptor = Object.getOwnPropertyDescriptor(element, propName);
17
- const nativeDescriptor = Object.getOwnPropertyDescriptor(element.constructor.prototype, propName);
18
-
19
- if (descriptor && nativeDescriptor) {
20
- Object.defineProperty(element, propName, nativeDescriptor);
21
- }
22
-
23
- element[propName] = propValue;
24
-
25
- if (descriptor) {
26
- Object.defineProperty(element, propName, descriptor);
27
- }
28
- }