From bbce58f058f234450363ace6a8031901df7b48db Mon Sep 17 00:00:00 2001 From: Lauri Rooden Date: Sat, 31 Dec 2022 02:17:53 +0200 Subject: [PATCH] Handle one level nested parentheses --- index.js | 6 +++--- test/index.js | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 1ac60c6..c19372a 100644 --- a/index.js +++ b/index.js @@ -11,9 +11,9 @@ !function(exports) { var undef - , selectorRe = /([.#:[])([-\w]+)(?:\((.+?)\)|([~^$*|]?)=(("|')(?:\\.|[^\\])*?\6|[-\w]+))?]?/g - , selectorLastRe = /([\s>+~]*)(?:("|')(?:\\.|[^\\])*?\2|\(.+?\)|~=|[^\s>+~])+$/ - , selectorSplitRe = /\s*,\s*(?=(?:[^'"()]|"(?:\\.|[^\\])*?"|'(?:\\.|[^\\])*?'|\(.+?\))+$)/ + , selectorRe = /([.#:[])([-\w]+)(?:\(((?:[^()]|\([^)]+\))+?)\)|([~^$*|]?)=(("|')(?:\\.|[^\\])*?\6|[-\w]+))?]?/g + , selectorLastRe = /([\s>+~]*)(?:("|')(?:\\.|[^\\])*?\2|\((?:[^()]|\([^()]+\))+?\)|~=|[^\s>+~])+$/ + , selectorSplitRe = /\s*,\s*(?=(?:[^'"()]|"(?:\\.|[^\\"])*?"|'(?:\\.|[^\\'])*?'|\((?:[^()]|\([^()]+\))+?\))+$)/ , selectorCache = { "": function() {} } diff --git a/test/index.js b/test/index.js index b1fab68..b5b214a 100644 --- a/test/index.js +++ b/test/index.js @@ -268,6 +268,7 @@ describe("selector-lite", function() { assert.equal(el1.matches("div:not(:only-of-type)"), false) assert.equal(el1.matches("div:is(:first-child, :last-child)"), true) + assert.equal(el1.matches("div:is(:not(:last-child))"), true) assert.equal(el1.matches("div:last-child"), false) assert.equal(el1.matches("div:not(:last-child)"), true) assert.equal(el1.matches("div:is(:first-child, :last-child)"), true)