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