Skip to content

Commit ae476d2

Browse files
authored
Expand what is considered to be a valid tag name to include underscores: (#41)
- was making this change for <wix-image> on Wix websites, but discovered after that this has already been done in e4593ff - have tested document.createElement('wix-image') and document.createElement('foo_bar'), but can't find a canonical source for what is allowed in tag names. - this restriction was originally introduced in #150 to prevent document.createElement('alt=""') i.e. a very malformed tag name
1 parent db28bc4 commit ae476d2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/snapshot.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
} from './types';
1010

1111
let _id = 1;
12-
const symbolAndNumberRegex = RegExp('[^a-z1-6-]');
12+
const tagNameRegex = RegExp('[^a-z1-6-_]');
1313

1414
function genId(): number {
1515
return _id++;
@@ -18,7 +18,7 @@ function genId(): number {
1818
function getValidTagName(tagName: string): string {
1919
const processedTagName = tagName.toLowerCase().trim();
2020

21-
if (symbolAndNumberRegex.test(processedTagName)) {
21+
if (tagNameRegex.test(processedTagName)) {
2222
// if the tag name is odd and we cannot extract
2323
// anything from the string, then we return a
2424
// generic div

0 commit comments

Comments
 (0)