change(tracker): change enum export, remoe attrs from hidden containers

This commit is contained in:
sylenien 2022-09-13 11:32:35 +02:00 committed by Delirium
parent 9156ffdf54
commit 73597913ff
3 changed files with 13 additions and 3 deletions

View file

@ -37,6 +37,8 @@ function isObservable(node: Node): boolean {
return !isIgnored(node)
}
const BASE_ATTRS = ['style', 'class']
/*
TODO:
- fix unbinding logic + send all removals first (ensure sequence is correct)
@ -291,8 +293,14 @@ export default abstract class Observer {
const width = el.clientWidth
const height = el.clientHeight
el = node.cloneNode() as Element
;(el as HTMLElement | SVGElement).style.width = width + 'px'
;(el as HTMLElement | SVGElement).style.height = height + 'px'
const attrs = el.getAttributeNames()
attrs.forEach((attr) => {
if (!attr.startsWith('data-openreplay') && !BASE_ATTRS.includes(attr)) {
el.removeAttribute(attr)
}
})
;(el as HTMLElement | SVGElement).style.width = `${width}px`
;(el as HTMLElement | SVGElement).style.height = `${height}px`
}
this.app.send(CreateElementNode(id, parentID, index, el.tagName, isSVGElement(node)))

View file

@ -2,7 +2,7 @@ import type App from './index.js'
import { stars, hasOpenreplayAttribute } from '../utils.js'
import { isElementNode } from './guards.js'
export declare const enum SanitizeLevel {
export enum SanitizeLevel {
Plain,
Obscured,
Hidden,

View file

@ -4,6 +4,8 @@ export { default as App } from './app/index.js'
import { UserID, UserAnonymousID, RawCustomEvent, CustomIssue } from './app/messages.gen.js'
import * as _Messages from './app/messages.gen.js'
export const Messages = _Messages
import { SanitizeLevel as SanitizeEnum } from './app/sanitizer.js'
export const SanitizeLevel = SanitizeEnum
import Connection from './modules/connection.js'
import Console from './modules/console.js'