Removing global document references (#1482)
fix for options `recordCanvas: true`: * replace document.createElement with doc.createElement in rrweb-snapshot code * Eoghan: add a regression test to prevent future accidental use of `document` instead of `doc`. This test can be excised if a new feature can only be run in the browser and not in the jsdom environment
This commit is contained in:
@@ -294,7 +294,7 @@ function buildNode(
|
||||
const value = specialAttributes[name];
|
||||
// handle internal attributes
|
||||
if (tagName === 'canvas' && name === 'rr_dataURL') {
|
||||
const image = document.createElement('img');
|
||||
const image = doc.createElement('img');
|
||||
image.onload = () => {
|
||||
const ctx = (node as HTMLCanvasElement).getContext('2d');
|
||||
if (ctx) {
|
||||
|
||||
@@ -726,7 +726,7 @@ function serializeElementNode(
|
||||
);
|
||||
|
||||
// create blank canvas of same dimensions
|
||||
const blankCanvas = document.createElement('canvas');
|
||||
const blankCanvas = doc.createElement('canvas');
|
||||
blankCanvas.width = (n as HTMLCanvasElement).width;
|
||||
blankCanvas.height = (n as HTMLCanvasElement).height;
|
||||
const blankCanvasDataURL = blankCanvas.toDataURL(
|
||||
|
||||
Reference in New Issue
Block a user