Exported MS Edge polyfill

This commit is contained in:
Rainer Simon 2020-05-08 20:57:22 +02:00
parent fc798b9e12
commit 4f5bab8237
2 changed files with 19 additions and 14 deletions

View File

@ -4,8 +4,9 @@ import Highlighter from './highlighter/Highlighter';
import SelectionHandler from './selection/SelectionHandler';
import RelationsLayer from './relations/RelationsLayer';
import RelationEditor from './relations/editor/RelationEditor';
import { addPolyfills } from './utils/MSEdgePolyfills';
import './utils/MSEdgePolyfills';
addPolyfills(); // For Microsoft Edge
/**
* Pulls the strings between the annotation highlight layer

View File

@ -1,9 +1,11 @@
if (!Element.prototype.matches) {
export const addPolyfills = () => {
if (!Element.prototype.matches) {
Element.prototype.matches = Element.prototype.msMatchesSelector ||
Element.prototype.webkitMatchesSelector;
}
}
if (!Element.prototype.closest) {
if (!Element.prototype.closest) {
Element.prototype.closest = function(s) {
let el = this;
@ -13,4 +15,6 @@ if (!Element.prototype.closest) {
} while (el !== null && el.nodeType === 1);
return null;
};
}
}