feat(core): remove unused keyboardEventShimIE test helper

This commit is contained in:
gvangeest 2021-12-29 13:03:31 +01:00
parent 2b583ee750
commit 495cb0c500
5 changed files with 6 additions and 53 deletions

View file

@ -0,0 +1,6 @@
---
'@lion/core': minor
'@lion/calendar': minor
---
Remove keyboardEventShimIE test helper

View file

@ -1,5 +1,4 @@
import { html } from '@lion/core';
import '@lion/core/test-helpers';
import { localize } from '@lion/localize';
import { localizeTearDown } from '@lion/localize/test-helpers';
import { expect, fixture as _fixture } from '@open-wc/testing';

View file

@ -19,7 +19,6 @@
"docs",
"src",
"test",
"test-helpers",
"translations",
"types"
],
@ -48,7 +47,6 @@
},
"exports": {
".": "./index.js",
"./test-helpers": "./test-helpers/index.js",
"./closestPolyfill": "./src/closestPolyfill.js",
"./docs/*": "./docs/*"
}

View file

@ -1 +0,0 @@
export * from './keyboardEventShimIE.js';

View file

@ -1,49 +0,0 @@
if (typeof window.KeyboardEvent !== 'function') {
// e.g. is IE and needs "polyfill"
const KeyboardEvent = (event, _params) => {
// current spec for it https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/KeyboardEvent
const params = {
bubbles: false,
cancelable: false,
view: document.defaultView,
key: false,
location: false,
ctrlKey: false,
shiftKey: false,
altKey: false,
metaKey: false,
repeat: false,
..._params,
};
const modifiersListArray = [];
if (params.ctrlKey) {
modifiersListArray.push('Control');
}
if (params.shiftKey) {
modifiersListArray.push('Shift');
}
if (params.altKey) {
modifiersListArray.push('Alt');
}
if (params.metaKey) {
modifiersListArray.push('Meta');
}
const ev = document.createEvent('KeyboardEvent');
// IE Spec for it https://technet.microsoft.com/en-us/windows/ff975297(v=vs.60)
ev.initKeyboardEvent(
event,
params.bubbles,
params.cancelable,
params.view,
params.key,
params.location,
modifiersListArray.join(' '),
params.repeat ? 1 : 0,
params.locale,
);
return ev;
};
KeyboardEvent.prototype = window.Event.prototype;
window.KeyboardEvent = KeyboardEvent;
}