compatibility fixes (#358)
* fix polyfill NodeList forEach * contentDocument.contains for IE * polyfill DOMTokenList forEach
This commit is contained in:
@@ -889,7 +889,15 @@ export class Replayer {
|
|||||||
return queue.push(mutation);
|
return queue.push(mutation);
|
||||||
}
|
}
|
||||||
|
|
||||||
const parentInDocument = this.iframe.contentDocument.contains(parent);
|
let parentInDocument = null;
|
||||||
|
if (this.iframe.contentDocument.contains) {
|
||||||
|
parentInDocument = this.iframe.contentDocument.contains(parent);
|
||||||
|
} else if (this.iframe.contentDocument.body.contains) {
|
||||||
|
// fix for IE
|
||||||
|
// refer 'Internet Explorer notes' at https://developer.mozilla.org/zh-CN/docs/Web/API/Document
|
||||||
|
parentInDocument = this.iframe.contentDocument.body.contains(parent);
|
||||||
|
}
|
||||||
|
|
||||||
if (useVirtualParent && parentInDocument) {
|
if (useVirtualParent && parentInDocument) {
|
||||||
const virtualParent = (document.createDocumentFragment() as unknown) as INode;
|
const virtualParent = (document.createDocumentFragment() as unknown) as INode;
|
||||||
mirror.map[mutation.parentId] = virtualParent;
|
mirror.map[mutation.parentId] = virtualParent;
|
||||||
|
|||||||
@@ -226,6 +226,11 @@ export function polyfill(win = window) {
|
|||||||
win.NodeList.prototype.forEach = (Array.prototype
|
win.NodeList.prototype.forEach = (Array.prototype
|
||||||
.forEach as unknown) as NodeList['forEach'];
|
.forEach as unknown) as NodeList['forEach'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ('DOMTokenList' in win && !win.DOMTokenList.prototype.forEach) {
|
||||||
|
win.DOMTokenList.prototype.forEach = (Array.prototype
|
||||||
|
.forEach as unknown) as DOMTokenList['forEach'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function needCastInSyncMode(event: eventWithTime): boolean {
|
export function needCastInSyncMode(event: eventWithTime): boolean {
|
||||||
|
|||||||
Reference in New Issue
Block a user