-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: lint errors from adding recordDOM
option
#1334
Changes from all commits
098b44a
6335b8e
2d6f604
b6e2d9f
789b67d
5b1694b
aa7bc38
95a3f68
f89b7fd
101efe6
c03d924
e8f4545
9d3d9f2
b99c2be
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -385,11 +385,6 @@ | |
iframeEl.addEventListener('load', listener); | ||
} | ||
|
||
function isStylesheetLoaded(link: HTMLLinkElement) { | ||
if (!link.getAttribute('href')) return true; // nothing to load | ||
return link.sheet !== null; | ||
} | ||
|
||
Comment on lines
-388
to
-392
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unused and not exported |
||
function onceStylesheetLoaded( | ||
link: HTMLLinkElement, | ||
listener: () => unknown, | ||
|
@@ -554,7 +549,7 @@ | |
// So we'll be conservative and keep textContent as-is. | ||
} else if ((n.parentNode as HTMLStyleElement).sheet?.cssRules) { | ||
textContent = stringifyStylesheet( | ||
(n.parentNode as HTMLStyleElement).sheet!, | ||
); | ||
} | ||
} catch (err) { | ||
|
@@ -648,7 +643,7 @@ | |
if (cssText) { | ||
delete attributes.rel; | ||
delete attributes.href; | ||
attributes._cssText = absoluteToStylesheet(cssText, stylesheet!.href!); | ||
Check warning on line 646 in packages/rrweb-snapshot/src/snapshot.ts GitHub Actions / ESLint Report Analysispackages/rrweb-snapshot/src/snapshot.ts#L646
|
||
} | ||
} | ||
// dynamic stylesheet | ||
|
@@ -742,10 +737,10 @@ | |
const recordInlineImage = () => { | ||
image.removeEventListener('load', recordInlineImage); | ||
try { | ||
canvasService!.width = image.naturalWidth; | ||
canvasService!.height = image.naturalHeight; | ||
canvasCtx!.drawImage(image, 0, 0); | ||
attributes.rr_dataURL = canvasService!.toDataURL( | ||
dataURLOptions.type, | ||
dataURLOptions.quality, | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
import type { Mirror } from 'rrweb-snapshot'; | ||
import { | ||
blockClass, | ||
CanvasContext, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -882,9 +882,10 @@ | |
const sn = (mirror as TMirror).getMeta(builtNode as unknown as TNode); | ||
if ( | ||
sn?.type === NodeType.Element && | ||
sn?.tagName.toUpperCase() === 'HTML' | ||
sn?.tagName.toUpperCase() === 'HTML' && | ||
iframeEl.contentDocument | ||
) { | ||
const { documentElement, head } = iframeEl.contentDocument!; | ||
const { documentElement, head } = iframeEl.contentDocument; | ||
this.insertStyleRules( | ||
documentElement as HTMLElement | RRElement, | ||
head as HTMLElement | RRElement, | ||
|
@@ -902,15 +903,18 @@ | |
} | ||
}; | ||
|
||
buildNodeWithSN(mutation.node, { | ||
doc: iframeEl.contentDocument! as Document, | ||
mirror: mirror as Mirror, | ||
hackCss: true, | ||
skipChild: false, | ||
afterAppend, | ||
cache: this.cache, | ||
}); | ||
afterAppend(iframeEl.contentDocument! as Document, mutation.node.id); | ||
if (iframeEl.contentDocument) { | ||
buildNodeWithSN(mutation.node, { | ||
// TODO: this cast is problematic as `iframEl.contentDocument` can be a `RRDocument` | ||
doc: iframeEl.contentDocument as Document, | ||
mirror: mirror as Mirror, | ||
hackCss: true, | ||
skipChild: false, | ||
afterAppend, | ||
cache: this.cache, | ||
}); | ||
afterAppend(iframeEl.contentDocument as Document, mutation.node.id); | ||
} | ||
|
||
for (const { mutationInQueue, builtNode } of collected) { | ||
this.attachDocumentToIframe(mutationInQueue, builtNode); | ||
|
@@ -997,9 +1001,10 @@ | |
* pause when there are some canvas drawImage args need to be loaded | ||
*/ | ||
private async preloadAllImages(): Promise<void[]> { | ||
let beforeLoadState = this.service.state; | ||
// TODO `_beforeLoadState` here does not seem to be used? | ||
let _beforeLoadState = this.service.state; | ||
const stateHandler = () => { | ||
beforeLoadState = this.service.state; | ||
_beforeLoadState = this.service.state; | ||
}; | ||
this.emitter.on(ReplayerEvents.Start, stateHandler); | ||
this.emitter.on(ReplayerEvents.Pause, stateHandler); | ||
|
@@ -1031,9 +1036,10 @@ | |
const canvas = document.createElement('canvas'); | ||
const ctx = canvas.getContext('2d'); | ||
const imgd = ctx?.createImageData(canvas.width, canvas.height); | ||
let d = imgd?.data; | ||
d = JSON.parse(data.args[0]) as Uint8ClampedArray; | ||
ctx?.putImageData(imgd!, 0, 0); | ||
// TODO: `_d` is not being used, unless there are some side-effects | ||
let _d = imgd?.data; | ||
_d = JSON.parse(data.args[0]) as Uint8ClampedArray; | ||
imgd && ctx?.putImageData(imgd, 0, 0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't remove these because I wasn't sure if there were any side-effects |
||
} | ||
} | ||
private async deserializeAndPreloadCanvasEvents( | ||
|
@@ -1370,7 +1376,7 @@ | |
// Only apply virtual dom optimization if the fast-forward process has node mutation. Because the cost of creating a virtual dom tree and executing the diff algorithm is usually higher than directly applying other kind of events. | ||
if (this.config.useVirtualDom && !this.usingVirtualDom && isSync) { | ||
this.usingVirtualDom = true; | ||
buildFromDom(this.iframe.contentDocument!, this.mirror, this.virtualDom); | ||
// If these legacy missing nodes haven't been resolved, they should be converted to virtual nodes. | ||
if (Object.keys(this.legacy_missingNodeRetryMap).length) { | ||
for (const key in this.legacy_missingNodeRetryMap) { | ||
|
@@ -1487,7 +1493,7 @@ | |
// If the parent is attached a shadow dom after it's created, it won't have a shadow root. | ||
if (!hasShadowRoot(parent)) { | ||
(parent as Element | RRElement).attachShadow({ mode: 'open' }); | ||
parent = (parent as Element | RRElement).shadowRoot! as Node | RRNode; | ||
} else parent = parent.shadowRoot as Node | RRNode; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unused