mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-03 23:03:09 +00:00
fix: address review — PostHog key comment, flushTimer cleanup, TOCTOU, type guard
This commit is contained in:
@@ -55,6 +55,11 @@ export function removeElementFromHtml(source: string, target: SourceMutationTarg
|
||||
return wrappedFragment ? document.body.innerHTML || "" : document.toString();
|
||||
}
|
||||
|
||||
function isHTMLElement(el: Element): boolean {
|
||||
const HTMLEl = el.ownerDocument.defaultView?.HTMLElement;
|
||||
return HTMLEl ? el instanceof HTMLEl : "style" in el;
|
||||
}
|
||||
|
||||
export interface PatchOperation {
|
||||
type: "inline-style" | "attribute" | "html-attribute" | "text-content";
|
||||
property: string;
|
||||
@@ -68,7 +73,7 @@ export function patchElementInHtml(
|
||||
): string {
|
||||
const { document, wrappedFragment } = parseSourceDocument(source);
|
||||
const el = findTargetElement(document, target);
|
||||
if (!el || !(el instanceof (el.ownerDocument.defaultView?.HTMLElement ?? Element))) return source;
|
||||
if (!el || !isHTMLElement(el)) return source;
|
||||
const htmlEl = el as unknown as HTMLElement;
|
||||
|
||||
for (const op of operations) {
|
||||
|
||||
Reference in New Issue
Block a user