Skip to content

Commit

Permalink
fix: throw error for invalid tag name
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley committed Jan 23, 2022
1 parent 86fcda6 commit 9f865e6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/lib/web-worker/worker-constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,5 @@ export const windowGetterDimensionMethodNames = ['getComputedStyle'];
export const eventTargetMethods = /*#__PURE__*/ commaSplit(
'addEventListener,dispatchEvent,removeEventListener'
);

export const IS_TAG_REG = /^[A-Z]([A-Z0-9-]*[A-Z0-9])?$/;
5 changes: 4 additions & 1 deletion src/lib/web-worker/worker-document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { getInstanceStateValue } from './worker-state';
import { getOrCreateNodeInstance } from './worker-constructors';
import { getPartytownScript } from './worker-exec';
import { isScriptJsType } from './worker-script';
import { IS_TAG_REG, WinIdKey } from './worker-constants';
import type { Node } from './worker-node';
import { noop, randomId, SCRIPT_TYPE } from '../utils';
import { WinIdKey } from './worker-constants';

export const DocumentDescriptorMap: PropertyDescriptorMap & ThisType<Node> = {
body: {
Expand All @@ -19,6 +19,9 @@ export const DocumentDescriptorMap: PropertyDescriptorMap & ThisType<Node> = {
createElement: {
value(tagName: string) {
tagName = tagName.toUpperCase();
if (!IS_TAG_REG.test(tagName)) {
throw tagName + ' not valid';
}

const winId = this[WinIdKey];
const instanceId = randomId();
Expand Down

1 comment on commit 9f865e6

@vercel
Copy link

@vercel vercel bot commented on 9f865e6 Jan 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.