add mask all inputs option to snapshot
This commit is contained in:
@@ -100,6 +100,7 @@ function serializeNode(
|
|||||||
doc: Document,
|
doc: Document,
|
||||||
blockClass: string | RegExp,
|
blockClass: string | RegExp,
|
||||||
inlineStylesheet: boolean,
|
inlineStylesheet: boolean,
|
||||||
|
maskAllInputs: boolean,
|
||||||
): serializedNode | false {
|
): serializedNode | false {
|
||||||
switch (n.nodeType) {
|
switch (n.nodeType) {
|
||||||
case n.DOCUMENT_NODE:
|
case n.DOCUMENT_NODE:
|
||||||
@@ -177,7 +178,7 @@ function serializeNode(
|
|||||||
attributes.type !== 'checkbox' &&
|
attributes.type !== 'checkbox' &&
|
||||||
value
|
value
|
||||||
) {
|
) {
|
||||||
attributes.value = value;
|
attributes.value = maskAllInputs ? '*'.repeat(value.length) : value;
|
||||||
} else if ((n as HTMLInputElement).checked) {
|
} else if ((n as HTMLInputElement).checked) {
|
||||||
attributes.checked = (n as HTMLInputElement).checked;
|
attributes.checked = (n as HTMLInputElement).checked;
|
||||||
}
|
}
|
||||||
@@ -241,8 +242,15 @@ export function serializeNodeWithId(
|
|||||||
blockClass: string | RegExp,
|
blockClass: string | RegExp,
|
||||||
skipChild = false,
|
skipChild = false,
|
||||||
inlineStylesheet = true,
|
inlineStylesheet = true,
|
||||||
|
maskAllInputs = false,
|
||||||
): serializedNodeWithId | null {
|
): serializedNodeWithId | null {
|
||||||
const _serializedNode = serializeNode(n, doc, blockClass, inlineStylesheet);
|
const _serializedNode = serializeNode(
|
||||||
|
n,
|
||||||
|
doc,
|
||||||
|
blockClass,
|
||||||
|
inlineStylesheet,
|
||||||
|
maskAllInputs,
|
||||||
|
);
|
||||||
if (!_serializedNode) {
|
if (!_serializedNode) {
|
||||||
// TODO: dev only
|
// TODO: dev only
|
||||||
console.warn(n, 'not serialized');
|
console.warn(n, 'not serialized');
|
||||||
@@ -290,10 +298,19 @@ function snapshot(
|
|||||||
n: Document,
|
n: Document,
|
||||||
blockClass: string | RegExp = 'rr-block',
|
blockClass: string | RegExp = 'rr-block',
|
||||||
inlineStylesheet = true,
|
inlineStylesheet = true,
|
||||||
|
maskAllInputs = false,
|
||||||
): [serializedNodeWithId | null, idNodeMap] {
|
): [serializedNodeWithId | null, idNodeMap] {
|
||||||
const idNodeMap: idNodeMap = {};
|
const idNodeMap: idNodeMap = {};
|
||||||
return [
|
return [
|
||||||
serializeNodeWithId(n, n, idNodeMap, blockClass, false, inlineStylesheet),
|
serializeNodeWithId(
|
||||||
|
n,
|
||||||
|
n,
|
||||||
|
idNodeMap,
|
||||||
|
blockClass,
|
||||||
|
false,
|
||||||
|
inlineStylesheet,
|
||||||
|
maskAllInputs,
|
||||||
|
),
|
||||||
idNodeMap,
|
idNodeMap,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user