@fluixi-css/core 1.0.0-next.4 → 1.0.0-next.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/dist/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Fluixi CSS engine — a fast, CSS-first utility engine (compile, transform, theming, source maps).",
4
4
  "license": "MIT",
5
5
  "author": "fluixi",
6
- "version": "1.0.0-next.4",
6
+ "version": "1.0.0-next.5",
7
7
  "private": false,
8
8
  "sideEffects": false,
9
9
  "repository": {
@@ -912,7 +912,7 @@ var CssParser = /*#__PURE__*/function () {
912
912
  var comment = this.parseComment();
913
913
  return this.options.includeComments ? comment : null;
914
914
  }
915
- if (c === CC_AT) return this.parseAtRule();
915
+ if (c === CC_AT) return this.parseAtRule(mode);
916
916
  switch (mode) {
917
917
  case 'keyframes':
918
918
  return this.parseKeyframeStop();
@@ -934,9 +934,13 @@ var CssParser = /*#__PURE__*/function () {
934
934
  }
935
935
 
936
936
  // ── At-rule ───────────────────────────────────────────────────────────────
937
+
938
+ /** `parent` is the block the at-rule sits in: inside a style rule, a conditional group's
939
+ * body follows the rule's grammar (CSS Nesting), declarations and nested rules. */
937
940
  }, {
938
941
  key: "parseAtRule",
939
942
  value: function parseAtRule() {
943
+ var parent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'stylesheet';
940
944
  if (this.peek() !== CC_AT) return null;
941
945
  var locStart = this.locPos();
942
946
  this.advance(); // '@'
@@ -961,7 +965,7 @@ var CssParser = /*#__PURE__*/function () {
961
965
  if (vp) ar.vendorPrefix = vp[0];
962
966
  }
963
967
  if (this.peek() === CC_LBRACE) {
964
- var mode = this.modeForAtRule(baseName);
968
+ var mode = this.modeForAtRule(baseName, parent);
965
969
  var blockStart = this.locPos();
966
970
  var children = this.parseBlockChildren(mode);
967
971
  var blockEnd = this.locPos();
@@ -1002,6 +1006,7 @@ var CssParser = /*#__PURE__*/function () {
1002
1006
  }, {
1003
1007
  key: "modeForAtRule",
1004
1008
  value: function modeForAtRule(baseName) {
1009
+ var parent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'stylesheet';
1005
1010
  // AWC encodes comments as @comment-XXXXXXXX { --rule-...: "..."; }
1006
1011
  // which contain only declarations — must NOT use mixed/rule mode or
1007
1012
  // readUntilLBrace() will consume past the closing } and corrupt state.
@@ -1021,13 +1026,16 @@ var CssParser = /*#__PURE__*/function () {
1021
1026
  // as a selector and corrupt the block.)
1022
1027
  case 'utility':
1023
1028
  return 'rule';
1029
+ // Nested in a style rule, `@media { color: red }` holds declarations: read in
1030
+ // `mixed` mode, `color: red` became a selector that ran past the closing brace
1031
+ // and swallowed every rule after it.
1024
1032
  case 'media':
1025
1033
  case 'supports':
1026
1034
  case 'container':
1027
1035
  case 'layer':
1028
1036
  case 'document':
1029
1037
  default:
1030
- return 'mixed';
1038
+ return parent === 'rule' ? 'rule' : 'mixed';
1031
1039
  }
1032
1040
  }
1033
1041