@acemir/cssom 0.9.28 → 0.9.29
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 +38 -23
- package/lib/parse.js +38 -23
- package/package.json +1 -1
package/build/CSSOM.js
CHANGED
|
@@ -5264,37 +5264,52 @@ CSSOM.parse = function parse(token, opts, errorHandler) {
|
|
|
5264
5264
|
break;
|
|
5265
5265
|
}
|
|
5266
5266
|
|
|
5267
|
+
// Find the actual parent rule by popping from ancestor stack
|
|
5267
5268
|
while (ancestorRules.length > 0) {
|
|
5268
5269
|
parentRule = ancestorRules.pop();
|
|
5269
5270
|
|
|
5270
|
-
if
|
|
5271
|
-
|
|
5272
|
-
|
|
5273
|
-
|
|
5274
|
-
|
|
5275
|
-
|
|
5276
|
-
|
|
5277
|
-
|
|
5278
|
-
|
|
5279
|
-
|
|
5280
|
-
|
|
5281
|
-
|
|
5282
|
-
|
|
5283
|
-
|
|
5284
|
-
|
|
5285
|
-
|
|
5286
|
-
|
|
5287
|
-
|
|
5288
|
-
|
|
5289
|
-
|
|
5290
|
-
|
|
5291
|
-
|
|
5271
|
+
// Skip if we popped the current scope itself (happens because we push both rule and parent)
|
|
5272
|
+
if (parentRule === currentScope) {
|
|
5273
|
+
continue;
|
|
5274
|
+
}
|
|
5275
|
+
|
|
5276
|
+
// Only process valid grouping rules
|
|
5277
|
+
if (!(parentRule instanceof CSSOM.CSSGroupingRule && (parentRule.constructor.name !== 'CSSStyleRule' || parentRule.__parentRule))) {
|
|
5278
|
+
continue;
|
|
5279
|
+
}
|
|
5280
|
+
|
|
5281
|
+
// Determine if we're closing a special nested selector context
|
|
5282
|
+
var isClosingNestedSelectorContext = nestedSelectorRule &&
|
|
5283
|
+
(currentScope === nestedSelectorRule || nestedSelectorRule.__parentRule === currentScope);
|
|
5284
|
+
|
|
5285
|
+
if (isClosingNestedSelectorContext) {
|
|
5286
|
+
// Closing the nestedSelectorRule or its direct container
|
|
5287
|
+
if (nestedSelectorRule.parentRule) {
|
|
5288
|
+
// Add nestedSelectorRule to its parent and update scope
|
|
5289
|
+
prevScope = nestedSelectorRule;
|
|
5290
|
+
currentScope = nestedSelectorRule.parentRule;
|
|
5291
|
+
if (currentScope.cssRules.indexOf(prevScope) === -1) {
|
|
5292
|
+
currentScope.cssRules.push(prevScope);
|
|
5292
5293
|
}
|
|
5294
|
+
nestedSelectorRule = currentScope;
|
|
5293
5295
|
} else {
|
|
5296
|
+
// Top-level CSSStyleRule with nested grouping rule
|
|
5294
5297
|
prevScope = currentScope;
|
|
5295
|
-
|
|
5298
|
+
var actualParent = ancestorRules.length > 0 ? ancestorRules[ancestorRules.length - 1] : nestedSelectorRule;
|
|
5299
|
+
if (actualParent !== prevScope) {
|
|
5300
|
+
actualParent.cssRules.push(prevScope);
|
|
5301
|
+
}
|
|
5302
|
+
currentScope = actualParent;
|
|
5303
|
+
parentRule = actualParent;
|
|
5296
5304
|
break;
|
|
5297
5305
|
}
|
|
5306
|
+
} else {
|
|
5307
|
+
// Regular case: add currentScope to parentRule
|
|
5308
|
+
prevScope = currentScope;
|
|
5309
|
+
if (parentRule !== prevScope) {
|
|
5310
|
+
parentRule.cssRules.push(prevScope);
|
|
5311
|
+
}
|
|
5312
|
+
break;
|
|
5298
5313
|
}
|
|
5299
5314
|
}
|
|
5300
5315
|
|
package/lib/parse.js
CHANGED
|
@@ -2293,37 +2293,52 @@ CSSOM.parse = function parse(token, opts, errorHandler) {
|
|
|
2293
2293
|
break;
|
|
2294
2294
|
}
|
|
2295
2295
|
|
|
2296
|
+
// Find the actual parent rule by popping from ancestor stack
|
|
2296
2297
|
while (ancestorRules.length > 0) {
|
|
2297
2298
|
parentRule = ancestorRules.pop();
|
|
2298
2299
|
|
|
2299
|
-
if
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2300
|
+
// Skip if we popped the current scope itself (happens because we push both rule and parent)
|
|
2301
|
+
if (parentRule === currentScope) {
|
|
2302
|
+
continue;
|
|
2303
|
+
}
|
|
2304
|
+
|
|
2305
|
+
// Only process valid grouping rules
|
|
2306
|
+
if (!(parentRule instanceof CSSOM.CSSGroupingRule && (parentRule.constructor.name !== 'CSSStyleRule' || parentRule.__parentRule))) {
|
|
2307
|
+
continue;
|
|
2308
|
+
}
|
|
2309
|
+
|
|
2310
|
+
// Determine if we're closing a special nested selector context
|
|
2311
|
+
var isClosingNestedSelectorContext = nestedSelectorRule &&
|
|
2312
|
+
(currentScope === nestedSelectorRule || nestedSelectorRule.__parentRule === currentScope);
|
|
2313
|
+
|
|
2314
|
+
if (isClosingNestedSelectorContext) {
|
|
2315
|
+
// Closing the nestedSelectorRule or its direct container
|
|
2316
|
+
if (nestedSelectorRule.parentRule) {
|
|
2317
|
+
// Add nestedSelectorRule to its parent and update scope
|
|
2318
|
+
prevScope = nestedSelectorRule;
|
|
2319
|
+
currentScope = nestedSelectorRule.parentRule;
|
|
2320
|
+
if (currentScope.cssRules.indexOf(prevScope) === -1) {
|
|
2321
|
+
currentScope.cssRules.push(prevScope);
|
|
2321
2322
|
}
|
|
2323
|
+
nestedSelectorRule = currentScope;
|
|
2322
2324
|
} else {
|
|
2325
|
+
// Top-level CSSStyleRule with nested grouping rule
|
|
2323
2326
|
prevScope = currentScope;
|
|
2324
|
-
|
|
2327
|
+
var actualParent = ancestorRules.length > 0 ? ancestorRules[ancestorRules.length - 1] : nestedSelectorRule;
|
|
2328
|
+
if (actualParent !== prevScope) {
|
|
2329
|
+
actualParent.cssRules.push(prevScope);
|
|
2330
|
+
}
|
|
2331
|
+
currentScope = actualParent;
|
|
2332
|
+
parentRule = actualParent;
|
|
2325
2333
|
break;
|
|
2326
2334
|
}
|
|
2335
|
+
} else {
|
|
2336
|
+
// Regular case: add currentScope to parentRule
|
|
2337
|
+
prevScope = currentScope;
|
|
2338
|
+
if (parentRule !== prevScope) {
|
|
2339
|
+
parentRule.cssRules.push(prevScope);
|
|
2340
|
+
}
|
|
2341
|
+
break;
|
|
2327
2342
|
}
|
|
2328
2343
|
}
|
|
2329
2344
|
|