change(tracker): unify hidden
This commit is contained in:
parent
c94dedbe65
commit
367047f702
4 changed files with 13 additions and 13 deletions
|
|
@ -259,7 +259,7 @@ export default abstract class Observer {
|
|||
return false
|
||||
}
|
||||
this.app.sanitizer.handleNode(id, parentID, node)
|
||||
if (this.app.sanitizer.isHiddenContainer(parentID)) {
|
||||
if (this.app.sanitizer.isHidden(parentID)) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
|
@ -287,7 +287,7 @@ export default abstract class Observer {
|
|||
if (isElementNode(node)) {
|
||||
let el: Element = node
|
||||
if (parentID !== undefined) {
|
||||
if (this.app.sanitizer.isHiddenContainer(id)) {
|
||||
if (this.app.sanitizer.isHidden(id)) {
|
||||
const width = el.clientWidth
|
||||
const height = el.clientHeight
|
||||
el = node.cloneNode() as Element
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ export interface Options {
|
|||
|
||||
export default class Sanitizer {
|
||||
private readonly obscured: Set<number> = new Set()
|
||||
private readonly hiddenContainers: Set<number> = new Set()
|
||||
private readonly hidden: Set<number> = new Set()
|
||||
private readonly options: Options
|
||||
|
||||
constructor(private readonly app: App, options: Partial<Options>) {
|
||||
|
|
@ -38,11 +38,11 @@ export default class Sanitizer {
|
|||
this.obscured.add(id)
|
||||
}
|
||||
if (
|
||||
this.hiddenContainers.has(parentID) ||
|
||||
this.hidden.has(parentID) ||
|
||||
(isElementNode(node) &&
|
||||
(hasOpenreplayAttribute(node, 'htmlmasked') || hasOpenreplayAttribute(node, 'hidden-html')))
|
||||
(hasOpenreplayAttribute(node, 'htmlmasked') || hasOpenreplayAttribute(node, 'hidden')))
|
||||
) {
|
||||
this.hiddenContainers.add(id)
|
||||
this.hidden.add(id)
|
||||
}
|
||||
|
||||
if (this.options.domSanitizer !== undefined && isElementNode(node)) {
|
||||
|
|
@ -51,7 +51,7 @@ export default class Sanitizer {
|
|||
this.obscured.add(id)
|
||||
}
|
||||
if (sanitizeLevel === SanitizeLevel.Hidden) {
|
||||
this.hiddenContainers.add(id)
|
||||
this.hidden.add(id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -79,12 +79,12 @@ export default class Sanitizer {
|
|||
return this.obscured.has(id)
|
||||
}
|
||||
|
||||
isHiddenContainer(id: number) {
|
||||
return this.hiddenContainers.has(id)
|
||||
isHidden(id: number) {
|
||||
return this.hidden.has(id)
|
||||
}
|
||||
|
||||
isMasked(id: number): boolean {
|
||||
return this.isObscured(id) || this.isHiddenContainer(id)
|
||||
return this.isObscured(id) || this.isHidden(id)
|
||||
}
|
||||
|
||||
getInnerTextSecure(el: HTMLElement): string {
|
||||
|
|
@ -97,6 +97,6 @@ export default class Sanitizer {
|
|||
|
||||
clear(): void {
|
||||
this.obscured.clear()
|
||||
this.hiddenContainers.clear()
|
||||
this.hidden.clear()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ export default function (app: App, opts: Partial<Options>): void {
|
|||
let value = node.value
|
||||
let inputMode: InputMode = options.defaultInputMode
|
||||
|
||||
if (node.type === 'password' || hasOpenreplayAttribute(node, 'hidden')) {
|
||||
if (node.type === 'password' || app.sanitizer.isHidden(id)) {
|
||||
inputMode = InputMode.Hidden
|
||||
} else if (
|
||||
app.sanitizer.isObscured(id) ||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
const DEPRECATED_ATTRS = { htmlmasked: 'hidden-html', masked: 'obscured' }
|
||||
const DEPRECATED_ATTRS = { htmlmasked: 'hidden', masked: 'obscured' }
|
||||
|
||||
export const IN_BROWSER = !(typeof window === 'undefined')
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue