Sha256: eb6ea23858a71c8948f763930dd22f65c814032d0a87192b96ec165aed596d27

Contents?: true

Size: 1.83 KB

Versions: 26

Compression:

Stored size: 1.83 KB

Contents

import './behavior/click.js';
import './behavior/cut.js';
import './behavior/keydown.js';
import './behavior/keypress.js';
import './behavior/keyup.js';
import './behavior/paste.js';
import { behavior } from './behavior/registry.js';
import { wrapEvent } from './wrapEvent.js';
import { isMouseEvent, isKeyboardEvent } from './eventMap.js';
import { createEvent } from './createEvent.js';

function dispatchUIEvent(target, type, init, preventDefault = false) {
    if (isMouseEvent(type) || isKeyboardEvent(type)) {
        init = {
            ...init,
            ...this.system.getUIEventModifiers()
        };
    }
    const event = createEvent(type, target, init);
    return dispatchEvent.call(this, target, event, preventDefault);
}
function dispatchEvent(target, event, preventDefault = false) {
    var _behavior_type;
    const type = event.type;
    const behaviorImplementation = preventDefault ? ()=>{} : (_behavior_type = behavior[type]) === null || _behavior_type === void 0 ? void 0 : _behavior_type.call(behavior, event, target, this);
    if (behaviorImplementation) {
        event.preventDefault();
        let defaultPrevented = false;
        Object.defineProperty(event, 'defaultPrevented', {
            get: ()=>defaultPrevented
        });
        Object.defineProperty(event, 'preventDefault', {
            value: ()=>{
                defaultPrevented = event.cancelable;
            }
        });
        wrapEvent(()=>target.dispatchEvent(event));
        if (!defaultPrevented) {
            behaviorImplementation();
        }
        return !defaultPrevented;
    }
    return wrapEvent(()=>target.dispatchEvent(event));
}
function dispatchDOMEvent(target, type, init) {
    const event = createEvent(type, target, init);
    wrapEvent(()=>target.dispatchEvent(event));
}

export { dispatchDOMEvent, dispatchEvent, dispatchUIEvent };

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
clapton-0.0.26 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/dispatchEvent.js
clapton-0.0.25 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/dispatchEvent.js
clapton-0.0.24 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/dispatchEvent.js
clapton-0.0.23 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/dispatchEvent.js
clapton-0.0.22 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/dispatchEvent.js
clapton-0.0.21 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/dispatchEvent.js
clapton-0.0.20 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/dispatchEvent.js
clapton-0.0.19 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/dispatchEvent.js
clapton-0.0.18 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/dispatchEvent.js
clapton-0.0.17 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/dispatchEvent.js
clapton-0.0.16 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/dispatchEvent.js
clapton-0.0.15 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/dispatchEvent.js
clapton-0.0.14 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/dispatchEvent.js
clapton-0.0.13 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/dispatchEvent.js
clapton-0.0.12 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/dispatchEvent.js
clapton-0.0.11 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/dispatchEvent.js
clapton-0.0.10 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/dispatchEvent.js
clapton-0.0.9 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/dispatchEvent.js
clapton-0.0.8 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/dispatchEvent.js
clapton-0.0.7 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/dispatchEvent.js