Skip to content

Commit c137a3b

Browse files
author
Mingze
authored
fix(ie): Add SVG contains polyfill (#575)
1 parent 13a2ef2 commit c137a3b

File tree

3 files changed

+20
-161
lines changed

3 files changed

+20
-161
lines changed

src/BoxAnnotations.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import './polyfill';
12
import getProp from 'lodash/get';
23
import BaseAnnotator from './common/BaseAnnotator';
34
import ImageAnnotator from './image/ImageAnnotator';

src/polyfill.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Add support for SVGElement.contains in IE11
2+
if (!SVGElement.prototype.contains) {
3+
Object.defineProperty(SVGElement.prototype, 'contains', {
4+
configurable: true,
5+
enumerable: false,
6+
writable: true,
7+
value: function contains(node: Node) {
8+
let n: Node | null = node;
9+
do {
10+
if (this === n) {
11+
return true;
12+
}
13+
n = n && n.parentNode;
14+
} while (n);
15+
16+
return false;
17+
},
18+
});
19+
}

src/utils/polyfill.js

Lines changed: 0 additions & 161 deletions
This file was deleted.

0 commit comments

Comments
 (0)