Skip to content

Commit

Permalink
Apply formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mydea authored and github-actions[bot] committed Mar 20, 2023
1 parent f36b26c commit 4a07be3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
6 changes: 5 additions & 1 deletion packages/rrweb-snapshot/src/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,11 @@ function serializeElementNode(
| HTMLSelectElement
| HTMLOptionElement;

const value = getInputValue(el, tagName.toUpperCase() as Uppercase<typeof tagName>, attributes.type);
const value = getInputValue(
el,
tagName.toUpperCase() as Uppercase<typeof tagName>,
attributes.type,
);
const checked = (n as HTMLInputElement).checked;
if (attributes.type !== 'submit' && attributes.type !== 'button' && value) {
attributes.value = maskInputValue({
Expand Down
13 changes: 8 additions & 5 deletions packages/rrweb-snapshot/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,15 +256,18 @@ export function isNodeMetaEqual(a: serializedNode, b: serializedNode): boolean {

export function getInputValue(
el:
| HTMLInputElement
| HTMLTextAreaElement
| HTMLSelectElement
| HTMLOptionElement,
| HTMLInputElement
| HTMLTextAreaElement
| HTMLSelectElement
| HTMLOptionElement,
tagName: Uppercase<string>,
type: attributes[string],
): string {
const normalizedType = typeof type === 'string' ? type.toLowerCase() : type;
if (tagName === 'INPUT' && (normalizedType === 'radio' || normalizedType === 'checkbox')) {
if (
tagName === 'INPUT' &&
(normalizedType === 'radio' || normalizedType === 'checkbox')
) {
// checkboxes & radio buttons return `on` as their el.value when no value is specified
// we only want to get the value if it is specified as `value='xxx'`
return el.getAttribute('value') || '';
Expand Down

0 comments on commit 4a07be3

Please sign in to comment.