From a489f98a6625fbd61067e2d4721c1204bd22ea45 Mon Sep 17 00:00:00 2001 From: Ayush Goyal Date: Fri, 25 Oct 2019 20:05:44 +0530 Subject: [PATCH] perf(compiler-dom): use makeMap instead of RegEx (#354) --- packages/compiler-dom/src/parserOptionsMinimal.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/compiler-dom/src/parserOptionsMinimal.ts b/packages/compiler-dom/src/parserOptionsMinimal.ts index 38b3e6a8..09cbcb0d 100644 --- a/packages/compiler-dom/src/parserOptionsMinimal.ts +++ b/packages/compiler-dom/src/parserOptionsMinimal.ts @@ -6,6 +6,12 @@ import { NodeTypes } from '@vue/compiler-core' import { isVoidTag, isHTMLTag, isSVGTag } from './tagConfig' +import { makeMap } from '@vue/shared' + +const isRawTextContainer = /*#__PURE__*/ makeMap( + 'style,iframe,script,noscript', + true +) export const enum DOMNamespaces { HTML = Namespaces.HTML, @@ -73,9 +79,7 @@ export const parserOptionsMinimal: ParserOptions = { if (tag === 'textarea' || tag === 'title') { return TextModes.RCDATA } - if ( - /^(?:style|xmp|iframe|noembed|noframes|script|noscript)$/i.test(tag) - ) { + if (isRawTextContainer(tag)) { return TextModes.RAWTEXT } }