From 113f3cfc9fe69aa4dfd549049acac855f5d3d127 Mon Sep 17 00:00:00 2001 From: Valery Aligorsky Date: Thu, 31 Jan 2019 17:45:31 +0100 Subject: [PATCH] fix(css-selectors): extend regex to include superscript in range, fix #27 --- index.js | 4 ++-- tests/test.js | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 428c2239..fdb98c9d 100644 --- a/index.js +++ b/index.js @@ -2,10 +2,10 @@ module.exports = parse; -var re_name = /^(?:\\.|[\w\-\u00c0-\uFFFF])+/, +var re_name = /^(?:\\.|[\w\-\u00b0-\uFFFF])+/, re_escape = /\\([\da-f]{1,6}\s?|(\s)|.)/ig, //modified version of https://github.com/jquery/sizzle/blob/master/src/sizzle.js#L87 - re_attr = /^\s*((?:\\.|[\w\u00c0-\uFFFF\-])+)\s*(?:(\S?)=\s*(?:(['"])([^]*?)\3|(#?(?:\\.|[\w\u00c0-\uFFFF\-])*)|)|)\s*(i)?\]/; + re_attr = /^\s*((?:\\.|[\w\u00b0-\uFFFF\-])+)\s*(?:(\S?)=\s*(?:(['"])([^]*?)\3|(#?(?:\\.|[\w\u00b0-\uFFFF\-])*)|)|)\s*(i)?\]/; var actionTypes = { __proto__: null, diff --git a/tests/test.js b/tests/test.js index eae54423..8c583c64 100644 --- a/tests/test.js +++ b/tests/test.js @@ -162,6 +162,21 @@ var tests = [ ], "Space after escaped space" ], + [ + ".m™²³", + [ + [ + { + type: "attribute", + name: "class", + action: "element", + value: "m™²³", + ignoreCase: false + } + ] + ], + "Special charecters in selector" + ], [ "\\61 ", [