12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.hover = hover;
- exports.unhover = unhover;
- var _dom = require("@testing-library/dom");
- var _utils = require("./utils");
- // includes `element`
- function getParentElements(element) {
- const parentElements = [element];
- let currentElement = element;
- while ((currentElement = currentElement.parentElement) != null) {
- parentElements.push(currentElement);
- }
- return parentElements;
- }
- function hover(element, init) {
- if ((0, _utils.isLabelWithInternallyDisabledControl)(element)) return;
- const parentElements = getParentElements(element).reverse();
- _dom.fireEvent.pointerOver(element, init);
- for (const el of parentElements) {
- _dom.fireEvent.pointerEnter(el, init);
- }
- if (!element.disabled) {
- _dom.fireEvent.mouseOver(element, (0, _utils.getMouseEventOptions)('mouseover', init));
- for (const el of parentElements) {
- _dom.fireEvent.mouseEnter(el, (0, _utils.getMouseEventOptions)('mouseenter', init));
- }
- }
- _dom.fireEvent.pointerMove(element, init);
- if (!element.disabled) {
- _dom.fireEvent.mouseMove(element, (0, _utils.getMouseEventOptions)('mousemove', init));
- }
- }
- function unhover(element, init) {
- if ((0, _utils.isLabelWithInternallyDisabledControl)(element)) return;
- const parentElements = getParentElements(element);
- _dom.fireEvent.pointerMove(element, init);
- if (!element.disabled) {
- _dom.fireEvent.mouseMove(element, (0, _utils.getMouseEventOptions)('mousemove', init));
- }
- _dom.fireEvent.pointerOut(element, init);
- for (const el of parentElements) {
- _dom.fireEvent.pointerLeave(el, init);
- }
- if (!element.disabled) {
- _dom.fireEvent.mouseOut(element, (0, _utils.getMouseEventOptions)('mouseout', init));
- for (const el of parentElements) {
- _dom.fireEvent.mouseLeave(el, (0, _utils.getMouseEventOptions)('mouseleave', init));
- }
- }
- }
|