From a334fa3e98fb898e21eb5edce39fd8a92f227131 Mon Sep 17 00:00:00 2001 From: Dmitry Semigradsky Date: Sun, 10 Jan 2021 01:59:07 +0300 Subject: [PATCH] fix(parse): Allow space after attribute selector modifier (#393) --- src/__fixtures__/out.json | 12 ++++++++++++ src/parse.ts | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/__fixtures__/out.json b/src/__fixtures__/out.json index e366526c..d523bc8c 100644 --- a/src/__fixtures__/out.json +++ b/src/__fixtures__/out.json @@ -11430,6 +11430,18 @@ } ] ], + "[ a=b i ]": [ + [ + { + "type": "attribute", + "namespace": null, + "name": "a", + "action": "equals", + "value": "b", + "ignoreCase": true + } + ] + ], "[id*=option1]": [ [ { diff --git a/src/parse.ts b/src/parse.ts index 7a258837..774f40ab 100644 --- a/src/parse.ts +++ b/src/parse.ts @@ -81,7 +81,7 @@ export type TraversalType = const reName = /^[^\\#]?(?:\\(?:[\da-f]{1,6}\s?|.)|[\w\-\u00b0-\uFFFF])+/; const reEscape = /\\([\da-f]{1,6}\s?|(\s)|.)/gi; // Modified version of https://github.com/jquery/sizzle/blob/master/src/sizzle.js#L87 -const reAttr = /^\s*(?:(\*|[-\w]*)\|)?((?:\\.|[\w\u00b0-\uFFFF-])+)\s*(?:(\S?)=\s*(?:(['"])((?:[^\\]|\\[^])*?)\4|(#?(?:\\.|[\w\u00b0-\uFFFF-])*)|)|)\s*([iIsS])?\]/; +const reAttr = /^\s*(?:(\*|[-\w]*)\|)?((?:\\.|[\w\u00b0-\uFFFF-])+)\s*(?:(\S?)=\s*(?:(['"])((?:[^\\]|\\[^])*?)\4|(#?(?:\\.|[\w\u00b0-\uFFFF-])*)|)|)\s*([iIsS])?\s*\]/; const actionTypes: { [key: string]: AttributeAction } = { undefined: "exists",