fix#110 add NodeList forEach polyfill
This commit is contained in:
@@ -1,6 +1,12 @@
|
|||||||
import { snapshot } from 'rrweb-snapshot';
|
import { snapshot } from 'rrweb-snapshot';
|
||||||
import initObservers from './observer';
|
import initObservers from './observer';
|
||||||
import { mirror, on, getWindowWidth, getWindowHeight } from '../utils';
|
import {
|
||||||
|
mirror,
|
||||||
|
on,
|
||||||
|
getWindowWidth,
|
||||||
|
getWindowHeight,
|
||||||
|
polyfill,
|
||||||
|
} from '../utils';
|
||||||
import {
|
import {
|
||||||
EventType,
|
EventType,
|
||||||
event,
|
event,
|
||||||
@@ -49,6 +55,8 @@ function record(options: recordOptions = {}): listenerHandler | undefined {
|
|||||||
throw new Error('emit function is required');
|
throw new Error('emit function is required');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
polyfill();
|
||||||
|
|
||||||
let lastFullSnapshotEvent: eventWithTime;
|
let lastFullSnapshotEvent: eventWithTime;
|
||||||
let incrementalSnapshotCount = 0;
|
let incrementalSnapshotCount = 0;
|
||||||
wrappedEmit = (e: eventWithTime, isCheckout?: boolean) => {
|
wrappedEmit = (e: eventWithTime, isCheckout?: boolean) => {
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ import {
|
|||||||
Handler,
|
Handler,
|
||||||
Emitter,
|
Emitter,
|
||||||
} from '../types';
|
} from '../types';
|
||||||
import { mirror } from '../utils';
|
import { mirror, polyfill } from '../utils';
|
||||||
import getInjectStyleRules from './styles/inject-style';
|
import getInjectStyleRules from './styles/inject-style';
|
||||||
import './styles/style.css';
|
import './styles/style.css';
|
||||||
|
|
||||||
const SKIP_TIME_THRESHOLD = 10 * 1000;
|
const SKIP_TIME_THRESHOLD = 10 * 1000;
|
||||||
@@ -78,6 +78,7 @@ export class Replayer {
|
|||||||
|
|
||||||
this.timer = new Timer(this.config);
|
this.timer = new Timer(this.config);
|
||||||
smoothscroll.polyfill();
|
smoothscroll.polyfill();
|
||||||
|
polyfill();
|
||||||
this.setupDom();
|
this.setupDom();
|
||||||
this.emitter.on('resize', this.handleResize as Handler);
|
this.emitter.on('resize', this.handleResize as Handler);
|
||||||
}
|
}
|
||||||
@@ -288,7 +289,9 @@ export class Replayer {
|
|||||||
const styleEl = document.createElement('style');
|
const styleEl = document.createElement('style');
|
||||||
const { documentElement, head } = this.iframe.contentDocument!;
|
const { documentElement, head } = this.iframe.contentDocument!;
|
||||||
documentElement!.insertBefore(styleEl, head);
|
documentElement!.insertBefore(styleEl, head);
|
||||||
const injectStylesRules = getInjectStyleRules(this.config.blockClass).concat(this.config.insertStyleRules);
|
const injectStylesRules = getInjectStyleRules(
|
||||||
|
this.config.blockClass,
|
||||||
|
).concat(this.config.insertStyleRules);
|
||||||
for (let idx = 0; idx < injectStylesRules.length; idx++) {
|
for (let idx = 0; idx < injectStylesRules.length; idx++) {
|
||||||
(styleEl.sheet! as CSSStyleSheet).insertRule(injectStylesRules[idx], idx);
|
(styleEl.sheet! as CSSStyleSheet).insertRule(injectStylesRules[idx], idx);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -163,3 +163,10 @@ export function isTouchEvent(
|
|||||||
): event is TouchEvent {
|
): event is TouchEvent {
|
||||||
return Boolean((event as TouchEvent).changedTouches);
|
return Boolean((event as TouchEvent).changedTouches);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function polyfill() {
|
||||||
|
if ('NodeList' in window && !NodeList.prototype.forEach) {
|
||||||
|
NodeList.prototype.forEach = (Array.prototype
|
||||||
|
.forEach as unknown) as NodeList['forEach'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user