@testing-library/user-event 14.2.4 → 14.2.5

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/dist/index.cjs CHANGED
@@ -1742,7 +1742,7 @@ function prepareInterceptor(element, propName, interceptorImpl) {
1742
1742
  const objectDescriptor = Object.getOwnPropertyDescriptor(element, propName);
1743
1743
  const target = (prototypeDescriptor == null ? void 0 : prototypeDescriptor.set) ? "set" : "value";
1744
1744
  if (typeof (prototypeDescriptor == null ? void 0 : prototypeDescriptor[target]) !== "function" || prototypeDescriptor[target][Interceptor]) {
1745
- return;
1745
+ throw new Error(`Element ${element.tagName} does not implement "${String(propName)}".`);
1746
1746
  }
1747
1747
  function intercept(...args) {
1748
1748
  const {
@@ -1961,7 +1961,7 @@ function prepareElement(el) {
1961
1961
  if (el[isPrepared]) {
1962
1962
  return;
1963
1963
  }
1964
- if ("value" in el) {
1964
+ if (isElementType(el, ["input", "textarea"])) {
1965
1965
  prepareValueInterceptor(el);
1966
1966
  prepareSelectionInterceptor(el);
1967
1967
  prepareRangeTextInterceptor(el);
package/dist/index.mjs CHANGED
@@ -1752,7 +1752,7 @@ function prepareInterceptor(element, propName, interceptorImpl) {
1752
1752
  const objectDescriptor = Object.getOwnPropertyDescriptor(element, propName);
1753
1753
  const target = (prototypeDescriptor == null ? void 0 : prototypeDescriptor.set) ? "set" : "value";
1754
1754
  if (typeof (prototypeDescriptor == null ? void 0 : prototypeDescriptor[target]) !== "function" || prototypeDescriptor[target][Interceptor]) {
1755
- return;
1755
+ throw new Error(`Element ${element.tagName} does not implement "${String(propName)}".`);
1756
1756
  }
1757
1757
  function intercept(...args) {
1758
1758
  const {
@@ -1968,7 +1968,7 @@ function prepareElement(el) {
1968
1968
  if (el[isPrepared]) {
1969
1969
  return;
1970
1970
  }
1971
- if ("value" in el) {
1971
+ if (isElementType(el, ["input", "textarea"])) {
1972
1972
  prepareValueInterceptor(el);
1973
1973
  prepareSelectionInterceptor(el);
1974
1974
  prepareRangeTextInterceptor(el);
@@ -1,7 +1,7 @@
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 Node, PropName extends keyof ElementType>(element: ElementType, propName: PropName, interceptorImpl: (this: ElementType, ...args: Params<ElementType[PropName]>) => {
4
+ export declare function prepareInterceptor<ElementType extends Element, PropName extends keyof ElementType>(element: ElementType, propName: PropName, interceptorImpl: (this: ElementType, ...args: Params<ElementType[PropName]>) => {
5
5
  /**
6
6
  * React tracks the changes on element properties.
7
7
  * This workaround tries to alter the DOM element without React noticing,
@@ -12,7 +12,7 @@ declare global {
12
12
  };
13
13
  }
14
14
  }
15
- export declare function prepareValueInterceptor(element: HTMLInputElement): void;
15
+ export declare function prepareValueInterceptor(element: HTMLInputElement | HTMLTextAreaElement): void;
16
16
  export declare function setUIValue(element: HTMLInputElement | HTMLTextAreaElement, value: string): void;
17
17
  export declare function getUIValue(element: HTMLInputElement | HTMLTextAreaElement): string;
18
18
  /** Flag the IDL value as clean. This does not change the value.*/
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testing-library/user-event",
3
- "version": "14.2.4",
3
+ "version": "14.2.5",
4
4
  "description": "Fire events the same way the user does",
5
5
  "keywords": [
6
6
  "react-testing-library",