@acemir/cssom 0.9.3 → 0.9.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/CSSOM.js +12 -8
- package/lib/parse.js +12 -8
- package/package.json +1 -1
package/build/CSSOM.js
CHANGED
|
@@ -1574,7 +1574,7 @@ Object.defineProperties(CSSOM.CSSLayerStatementRule.prototype, {
|
|
|
1574
1574
|
* @param {string} token
|
|
1575
1575
|
*/
|
|
1576
1576
|
CSSOM.parse = function parse(token, errorHandler) {
|
|
1577
|
-
errorHandler = errorHandler === undefined
|
|
1577
|
+
errorHandler = errorHandler === undefined ? (console && console.error) : errorHandler;
|
|
1578
1578
|
|
|
1579
1579
|
var i = 0;
|
|
1580
1580
|
|
|
@@ -1807,16 +1807,19 @@ CSSOM.parse = function parse(token, errorHandler) {
|
|
|
1807
1807
|
* - Class selectors (e.g., `.container`)
|
|
1808
1808
|
* - Attribute selectors (e.g., `[type="text"]`)
|
|
1809
1809
|
* - Pseudo-classes and pseudo-elements (e.g., `:hover`, `::before`, `:nth-child(2)`)
|
|
1810
|
+
* - Pseudo-classes with nested parentheses, including cases where parentheses are nested inside arguments,
|
|
1811
|
+
* such as `:has(.sel:nth-child(3n))`
|
|
1810
1812
|
* - The parent selector (`&`)
|
|
1811
1813
|
* - Combinators (`>`, `+`, `~`) with optional whitespace
|
|
1812
1814
|
* - Whitespace (descendant combinator)
|
|
1813
1815
|
*
|
|
1814
1816
|
* The pattern ensures that a string consists only of valid basic selector components,
|
|
1815
|
-
* possibly repeated and combined,
|
|
1817
|
+
* possibly repeated and combined, including pseudo-classes with nested parentheses,
|
|
1818
|
+
* but does not match full CSS selector groups separated by commas.
|
|
1816
1819
|
*
|
|
1817
1820
|
* @type {RegExp}
|
|
1818
1821
|
*/
|
|
1819
|
-
var basicSelectorRegExp = /^([a-zA-Z][a-zA-Z0-9_-]*|\*|#[a-zA-Z0-9_-]+|\.[a-zA-Z0-9_-]+|\[[^\[\]]*(?:\s+[iI])?\]|::?[a-zA-Z0-9_-]+(?:\([
|
|
1822
|
+
var basicSelectorRegExp = /^([a-zA-Z][a-zA-Z0-9_-]*|\*|#[a-zA-Z0-9_-]+|\.[a-zA-Z0-9_-]+|\[[^\[\]]*(?:\s+[iI])?\]|::?[a-zA-Z0-9_-]+(?:\(((?:[^()"]+|"[^"]*"|'[^']*'|\((?:[^()"]+|"[^"]*"|'[^']*')*\))*?)\))?|&|\s*[>+~]\s*|\s+)+$/;
|
|
1820
1823
|
|
|
1821
1824
|
/**
|
|
1822
1825
|
* Regular expression to match CSS pseudo-classes with arguments.
|
|
@@ -1825,16 +1828,17 @@ CSSOM.parse = function parse(token, errorHandler) {
|
|
|
1825
1828
|
*
|
|
1826
1829
|
* Capture groups:
|
|
1827
1830
|
* 1. The pseudo-class name (letters and hyphens).
|
|
1828
|
-
* 2. The argument inside the parentheses (
|
|
1831
|
+
* 2. The argument inside the parentheses (can contain nested parentheses, quoted strings, and other characters.).
|
|
1829
1832
|
*
|
|
1830
1833
|
* Global flag (`g`) is used to find all matches in the input string.
|
|
1831
1834
|
*
|
|
1832
|
-
* Example
|
|
1833
|
-
* -
|
|
1834
|
-
* -
|
|
1835
|
+
* Example matches:
|
|
1836
|
+
* - :nth-child(2n+1)
|
|
1837
|
+
* - :has(.sel:nth-child(3n))
|
|
1838
|
+
* - :not(".foo, .bar")
|
|
1835
1839
|
* @type {RegExp}
|
|
1836
1840
|
*/
|
|
1837
|
-
var globalPseudoClassRegExp = /:([a-zA-Z-]+)\(([^)]
|
|
1841
|
+
var globalPseudoClassRegExp = /:([a-zA-Z-]+)\(((?:[^()"]+|"[^"]*"|'[^']*'|\((?:[^()"]+|"[^"]*"|'[^']*')*\))*?)\)/g;
|
|
1838
1842
|
|
|
1839
1843
|
/**
|
|
1840
1844
|
* Parses a CSS selector string and splits it into parts, handling nested parentheses.
|
package/lib/parse.js
CHANGED
|
@@ -7,7 +7,7 @@ var CSSOM = {};
|
|
|
7
7
|
* @param {string} token
|
|
8
8
|
*/
|
|
9
9
|
CSSOM.parse = function parse(token, errorHandler) {
|
|
10
|
-
errorHandler = errorHandler === undefined
|
|
10
|
+
errorHandler = errorHandler === undefined ? (console && console.error) : errorHandler;
|
|
11
11
|
|
|
12
12
|
var i = 0;
|
|
13
13
|
|
|
@@ -240,16 +240,19 @@ CSSOM.parse = function parse(token, errorHandler) {
|
|
|
240
240
|
* - Class selectors (e.g., `.container`)
|
|
241
241
|
* - Attribute selectors (e.g., `[type="text"]`)
|
|
242
242
|
* - Pseudo-classes and pseudo-elements (e.g., `:hover`, `::before`, `:nth-child(2)`)
|
|
243
|
+
* - Pseudo-classes with nested parentheses, including cases where parentheses are nested inside arguments,
|
|
244
|
+
* such as `:has(.sel:nth-child(3n))`
|
|
243
245
|
* - The parent selector (`&`)
|
|
244
246
|
* - Combinators (`>`, `+`, `~`) with optional whitespace
|
|
245
247
|
* - Whitespace (descendant combinator)
|
|
246
248
|
*
|
|
247
249
|
* The pattern ensures that a string consists only of valid basic selector components,
|
|
248
|
-
* possibly repeated and combined,
|
|
250
|
+
* possibly repeated and combined, including pseudo-classes with nested parentheses,
|
|
251
|
+
* but does not match full CSS selector groups separated by commas.
|
|
249
252
|
*
|
|
250
253
|
* @type {RegExp}
|
|
251
254
|
*/
|
|
252
|
-
var basicSelectorRegExp = /^([a-zA-Z][a-zA-Z0-9_-]*|\*|#[a-zA-Z0-9_-]+|\.[a-zA-Z0-9_-]+|\[[^\[\]]*(?:\s+[iI])?\]|::?[a-zA-Z0-9_-]+(?:\([
|
|
255
|
+
var basicSelectorRegExp = /^([a-zA-Z][a-zA-Z0-9_-]*|\*|#[a-zA-Z0-9_-]+|\.[a-zA-Z0-9_-]+|\[[^\[\]]*(?:\s+[iI])?\]|::?[a-zA-Z0-9_-]+(?:\(((?:[^()"]+|"[^"]*"|'[^']*'|\((?:[^()"]+|"[^"]*"|'[^']*')*\))*?)\))?|&|\s*[>+~]\s*|\s+)+$/;
|
|
253
256
|
|
|
254
257
|
/**
|
|
255
258
|
* Regular expression to match CSS pseudo-classes with arguments.
|
|
@@ -258,16 +261,17 @@ CSSOM.parse = function parse(token, errorHandler) {
|
|
|
258
261
|
*
|
|
259
262
|
* Capture groups:
|
|
260
263
|
* 1. The pseudo-class name (letters and hyphens).
|
|
261
|
-
* 2. The argument inside the parentheses (
|
|
264
|
+
* 2. The argument inside the parentheses (can contain nested parentheses, quoted strings, and other characters.).
|
|
262
265
|
*
|
|
263
266
|
* Global flag (`g`) is used to find all matches in the input string.
|
|
264
267
|
*
|
|
265
|
-
* Example
|
|
266
|
-
* -
|
|
267
|
-
* -
|
|
268
|
+
* Example matches:
|
|
269
|
+
* - :nth-child(2n+1)
|
|
270
|
+
* - :has(.sel:nth-child(3n))
|
|
271
|
+
* - :not(".foo, .bar")
|
|
268
272
|
* @type {RegExp}
|
|
269
273
|
*/
|
|
270
|
-
var globalPseudoClassRegExp = /:([a-zA-Z-]+)\(([^)]
|
|
274
|
+
var globalPseudoClassRegExp = /:([a-zA-Z-]+)\(((?:[^()"]+|"[^"]*"|'[^']*'|\((?:[^()"]+|"[^"]*"|'[^']*')*\))*?)\)/g;
|
|
271
275
|
|
|
272
276
|
/**
|
|
273
277
|
* Parses a CSS selector string and splits it into parts, handling nested parentheses.
|