From 611a5150d287bd4f20353821f70956a95f60c726 Mon Sep 17 00:00:00 2001 From: Ignatius Bagus Date: Wed, 23 Jun 2021 21:50:07 +0700 Subject: [PATCH] use string match to simplify regexp --- src/compiler/compile/css/Selector.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compiler/compile/css/Selector.ts b/src/compiler/compile/css/Selector.ts index 49ba5e71e5..f255e5506a 100644 --- a/src/compiler/compile/css/Selector.ts +++ b/src/compiler/compile/css/Selector.ts @@ -147,7 +147,8 @@ export default class Selector { for (const block of this.blocks) { for (const selector of block.selectors) { if (selector.type === 'PseudoClassSelector' && selector.name === 'global') { - if (/[^\\],/.test(selector.children[0].value)) { + const match = selector.children[0].value.match(/\(.*?\)|([^\\],)/); + if (match && match[1]) { component.error(selector, { code: 'css-invalid-global-selector', message: ':global(...) must contain a single selector'