Skip to content

Commit

Permalink
Expand what is considered to be a valid tag name to include underscor…
Browse files Browse the repository at this point in the history
…es: (#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
  • Loading branch information
eoghanmurray authored Aug 21, 2020
1 parent db28bc4 commit ae476d2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from './types';

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

function genId(): number {
return _id++;
Expand All @@ -18,7 +18,7 @@ function genId(): number {
function getValidTagName(tagName: string): string {
const processedTagName = tagName.toLowerCase().trim();

if (symbolAndNumberRegex.test(processedTagName)) {
if (tagNameRegex.test(processedTagName)) {
// if the tag name is odd and we cannot extract
// anything from the string, then we return a
// generic div
Expand Down

0 comments on commit ae476d2

Please sign in to comment.