@barocss/kit 0.11.0 → 0.11.1
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/dist/index.cjs +44 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +44 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1235,6 +1235,48 @@ function isBalancedPrelude(text) {
|
|
|
1235
1235
|
return stack.length === 0 && !quote;
|
|
1236
1236
|
}
|
|
1237
1237
|
/**
|
|
1238
|
+
* #396: returns `selector` with every quoted string and every `[...]` group (brackets included, nested groups and
|
|
1239
|
+
* escapes inside them too) replaced by a NUL placeholder per character. Backslash escapes outside those regions
|
|
1240
|
+
* are kept verbatim; parentheses are kept. The placeholder is not an identifier character, so it ends a token.
|
|
1241
|
+
*/
|
|
1242
|
+
function maskStringsAndBrackets(selector) {
|
|
1243
|
+
let out = "";
|
|
1244
|
+
let quote = "";
|
|
1245
|
+
let bracket = 0;
|
|
1246
|
+
for (let i = 0; i < selector.length; i++) {
|
|
1247
|
+
const c = selector[i];
|
|
1248
|
+
const masked = quote !== "" || bracket > 0;
|
|
1249
|
+
if (c === "\\") {
|
|
1250
|
+
const pair = selector.slice(i, i + 2);
|
|
1251
|
+
out += masked ? "\0".repeat(pair.length) : pair;
|
|
1252
|
+
i++;
|
|
1253
|
+
continue;
|
|
1254
|
+
}
|
|
1255
|
+
if (quote) {
|
|
1256
|
+
if (c === quote) quote = "";
|
|
1257
|
+
out += "\0";
|
|
1258
|
+
continue;
|
|
1259
|
+
}
|
|
1260
|
+
if (c === "\"" || c === "'") {
|
|
1261
|
+
quote = c;
|
|
1262
|
+
out += "\0";
|
|
1263
|
+
continue;
|
|
1264
|
+
}
|
|
1265
|
+
if (c === "[") {
|
|
1266
|
+
bracket++;
|
|
1267
|
+
out += "\0";
|
|
1268
|
+
continue;
|
|
1269
|
+
}
|
|
1270
|
+
if (c === "]" && bracket > 0) {
|
|
1271
|
+
bracket--;
|
|
1272
|
+
out += "\0";
|
|
1273
|
+
continue;
|
|
1274
|
+
}
|
|
1275
|
+
out += masked ? "\0" : c;
|
|
1276
|
+
}
|
|
1277
|
+
return out;
|
|
1278
|
+
}
|
|
1279
|
+
/**
|
|
1238
1280
|
* #392: true when every top-level comma part of an emitted selector names `escapedClass` (a class selector
|
|
1239
1281
|
* already escaped with escapeClassName, including its leading dot) as a whole class token, or, when
|
|
1240
1282
|
* `allowNesting` is set, uses the nesting selector `&`. Escapes, quoted strings and bracket groups are skipped
|
|
@@ -1264,7 +1306,8 @@ function isScopedSelector(selector, escapedClass, allowNesting = false) {
|
|
|
1264
1306
|
}
|
|
1265
1307
|
}
|
|
1266
1308
|
parts.push(selector.slice(start));
|
|
1267
|
-
return parts.every((
|
|
1309
|
+
return parts.every((raw) => {
|
|
1310
|
+
const part = maskStringsAndBrackets(raw);
|
|
1268
1311
|
if (allowNesting && part.includes("&")) return true;
|
|
1269
1312
|
for (let at = part.indexOf(escapedClass); at !== -1; at = part.indexOf(escapedClass, at + 1)) {
|
|
1270
1313
|
if (at > 0 && part[at - 1] === "\\") continue;
|