diff --git a/src/snapshot.ts b/src/snapshot.ts index 81d8e83f..b3f161a8 100644 --- a/src/snapshot.ts +++ b/src/snapshot.ts @@ -18,8 +18,12 @@ function genId(): number { return _id++; } -function getValidTagName(tagName: string): string { - const processedTagName = tagName.toLowerCase().trim(); +function getValidTagName(element: HTMLElement): string { + if (element instanceof HTMLFormElement) { + return 'form'; + } + + const processedTagName = element.tagName.toLowerCase().trim(); if (tagNameRegex.test(processedTagName)) { // if the tag name is odd and we cannot extract @@ -223,7 +227,7 @@ function serializeNode( blockClass, blockSelector, ); - const tagName = getValidTagName((n as HTMLElement).tagName); + const tagName = getValidTagName(n as HTMLElement); let attributes: attributes = {}; for (const { name, value } of Array.from((n as HTMLElement).attributes)) { attributes[name] = transformAttribute(doc, name, value); diff --git a/test/__snapshots__/integration.ts.snap b/test/__snapshots__/integration.ts.snap index 43bb79cd..d7d76c6d 100644 --- a/test/__snapshots__/integration.ts.snap +++ b/test/__snapshots__/integration.ts.snap @@ -102,32 +102,36 @@ exports[`[html file]: dynamic-stylesheet.html 1`] = ` exports[`[html file]: form-fields.html 1`] = ` " - - - - form fields - -
- - - - - -
-" + + + + form fields + +
+ + + + + + +
+ + " `; exports[`[html file]: hover.html 1`] = ` diff --git a/test/html/form-fields.html b/test/html/form-fields.html index 50778d60..31a35afa 100644 --- a/test/html/form-fields.html +++ b/test/html/form-fields.html @@ -1,41 +1,42 @@ + + + + + form fields + - - - - - form fields - - - -
- - - - - -
- - - + +
+ + + + + + +
+ +