@acemir/cssom 0.9.11 → 0.9.13

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 CHANGED
@@ -354,7 +354,7 @@ Object.defineProperty(CSSOM.CSSStyleRule.prototype, "cssText", {
354
354
  valuesArr.push(this.cssRules.map(function(rule){ return rule.cssText }).join("\n "));
355
355
  values = valuesArr.join("\n ") + "\n}"
356
356
  } else {
357
- values = " {" + this.style.cssText + "}";
357
+ values = " { " + this.style.cssText + " }";
358
358
  }
359
359
  text = this.selectorText + values;
360
360
  } else {
@@ -602,7 +602,7 @@ Object.defineProperties(CSSOM.CSSMediaRule.prototype, {
602
602
  for (var i=0, length=this.cssRules.length; i < length; i++) {
603
603
  cssTexts.push(this.cssRules[i].cssText);
604
604
  }
605
- return "@media " + this.media.mediaText + " {" + cssTexts.join("") + "}";
605
+ return "@media " + this.media.mediaText + " {" + (cssTexts.length ? "\n " + cssTexts.join("\n ") : "") + "\n}";
606
606
  },
607
607
  configurable: true,
608
608
  enumerable: true
@@ -641,7 +641,7 @@ Object.defineProperties(CSSOM.CSSContainerRule.prototype, {
641
641
  for (var i=0, length=this.cssRules.length; i < length; i++) {
642
642
  cssTexts.push(this.cssRules[i].cssText);
643
643
  }
644
- return "@container " + this.containerText + " {" + cssTexts.join("") + "}";
644
+ return "@container " + this.containerText + " {" + (cssTexts.length ? "\n " + cssTexts.join("\n ") : "") + "\n}";
645
645
  },
646
646
  configurable: true,
647
647
  enumerable: true
@@ -670,7 +670,7 @@ Object.defineProperty(CSSOM.CSSSupportsRule.prototype, "cssText", {
670
670
  cssTexts.push(this.cssRules[i].cssText);
671
671
  }
672
672
 
673
- return "@supports " + this.conditionText + " {" + cssTexts.join("") + "}";
673
+ return "@supports " + this.conditionText + " {" + (cssTexts.length ? "\n " + cssTexts.join("\n ") : "") + "\n}";
674
674
  }
675
675
  });
676
676
 
@@ -864,7 +864,7 @@ CSSOM.CSSNamespaceRule.prototype.type = 10;
864
864
 
865
865
  Object.defineProperty(CSSOM.CSSNamespaceRule.prototype, "cssText", {
866
866
  get: function() {
867
- return "@namespace" + (this.prefix && " " + this.prefix) + " url(" + this.namespaceURI + ");";
867
+ return "@namespace" + (this.prefix && " " + this.prefix) + " url(\"" + this.namespaceURI + "\");";
868
868
  },
869
869
  set: function(cssText) {
870
870
  // Reset prefix and namespaceURI
@@ -883,10 +883,10 @@ Object.defineProperty(CSSOM.CSSNamespaceRule.prototype, "cssText", {
883
883
  }
884
884
 
885
885
  // Regex to match valid namespace syntax:
886
- // 1. [optional prefix] url("...") or [optional prefix] url('...') or [optional prefix] url()
886
+ // 1. [optional prefix] url("...") or [optional prefix] url('...') or [optional prefix] url() or [optional prefix] url(unquoted)
887
887
  // 2. [optional prefix] "..." or [optional prefix] '...'
888
888
  // The prefix must be a valid CSS identifier (letters, digits, hyphens, underscores, starting with letter or underscore)
889
- var re = /^(?:([a-zA-Z_][a-zA-Z0-9_-]*)\s+)?(?:url\(\s*(?:(['"])(.*?)\2\s*)?\)|(['"])(.*?)\4)$/;
889
+ var re = /^(?:([a-zA-Z_][a-zA-Z0-9_-]*)\s+)?(?:url\(\s*(?:(['"])(.*?)\2\s*|([^)]*?))\s*\)|(['"])(.*?)\5)$/;
890
890
  var match = text.match(re);
891
891
 
892
892
  if (match) {
@@ -894,13 +894,17 @@ Object.defineProperty(CSSOM.CSSNamespaceRule.prototype, "cssText", {
894
894
  if (match[1]) {
895
895
  this.prefix = match[1];
896
896
  }
897
- // If url(...) form
897
+ // If url(...) form with quotes
898
898
  if (typeof match[3] !== "undefined") {
899
899
  this.namespaceURI = match[3];
900
900
  }
901
+ // If url(...) form without quotes
902
+ else if (typeof match[4] !== "undefined") {
903
+ this.namespaceURI = match[4].trim();
904
+ }
901
905
  // If quoted string form
902
- else if (typeof match[5] !== "undefined") {
903
- this.namespaceURI = match[5];
906
+ else if (typeof match[6] !== "undefined") {
907
+ this.namespaceURI = match[6];
904
908
  }
905
909
  } else {
906
910
  throw new DOMException("Invalid @namespace rule", "InvalidStateError");
@@ -930,7 +934,7 @@ CSSOM.CSSFontFaceRule.prototype.type = 5;
930
934
  // http://www.opensource.apple.com/source/WebCore/WebCore-955.66.1/css/WebKitCSSFontFaceRule.cpp
931
935
  Object.defineProperty(CSSOM.CSSFontFaceRule.prototype, "cssText", {
932
936
  get: function() {
933
- return "@font-face {" + this.style.cssText + "}";
937
+ return "@font-face { " + this.style.cssText + " }";
934
938
  }
935
939
  });
936
940
 
@@ -958,7 +962,7 @@ Object.defineProperty(CSSOM.CSSHostRule.prototype, "cssText", {
958
962
  for (var i=0, length=this.cssRules.length; i < length; i++) {
959
963
  cssTexts.push(this.cssRules[i].cssText);
960
964
  }
961
- return "@host {" + cssTexts.join("") + "}";
965
+ return "@host {" + (cssTexts.length ? "\n " + cssTexts.join("\n ") : "") + "\n}";
962
966
  }
963
967
  });
964
968
 
@@ -986,7 +990,7 @@ Object.defineProperty(CSSOM.CSSStartingStyleRule.prototype, "cssText", {
986
990
  for (var i=0, length=this.cssRules.length; i < length; i++) {
987
991
  cssTexts.push(this.cssRules[i].cssText);
988
992
  }
989
- return "@starting-style {" + cssTexts.join("") + "}";
993
+ return "@starting-style {" + (cssTexts.length ? "\n " + cssTexts.join("\n ") : "") + "\n}";
990
994
  }
991
995
  });
992
996
 
@@ -1045,9 +1049,9 @@ CSSOM.CSSStyleSheet.prototype.insertRule = function(rule, index) {
1045
1049
  var ruleToParse = String(rule);
1046
1050
  var parsedSheet = CSSOM.parse(ruleToParse);
1047
1051
  if (parsedSheet.cssRules.length !== 1) {
1048
- var domExceptionName = "SyntaxError";
1052
+ var domExceptionName = DOMException.SYNTAX_ERR;
1049
1053
  if (ruleToParse.trimStart().startsWith('@namespace')) {
1050
- domExceptionName = "InvalidStateError";
1054
+ domExceptionName = DOMException.INVALID_STATE_ERR;
1051
1055
  }
1052
1056
  throw new DOMException("Failed to execute 'insertRule' on 'CSSStyleSheet': Failed to parse the rule '" + ruleToParse + "'.", domExceptionName);
1053
1057
  }
@@ -1080,14 +1084,14 @@ CSSOM.CSSStyleSheet.prototype.deleteRule = function(index) {
1080
1084
  index = 4294967296 + index;
1081
1085
  }
1082
1086
  if (index >= this.cssRules.length) {
1083
- throw new DOMException("Failed to execute 'deleteRule' on 'CSSStyleSheet': The index provided (" + index + ") is larger than the maximum index (" + this.cssRules.length + ").", "IndexSizeError");
1087
+ throw new DOMException("Failed to execute 'deleteRule' on 'CSSStyleSheet': The index provided (" + index + ") is larger than the maximum index (" + this.cssRules.length + ").", DOMException.INDEX_SIZE_ERR);
1084
1088
  }
1085
1089
  if (this.cssRules[index] && this.cssRules[index].constructor.name == "CSSNamespaceRule") {
1086
1090
  var shouldContinue = this.cssRules.every(function (rule) {
1087
1091
  return ['CSSImportRule','CSSLayerStatementRule','CSSNamespaceRule'].indexOf(rule.constructor.name) !== -1
1088
1092
  });
1089
1093
  if (!shouldContinue) {
1090
- throw new DOMException("Failed to execute 'deleteRule' on 'CSSStyleSheet': Deleting a CSSNamespaceRule is not allowed when there is rules other than @import, @layer statement, or @namespace.", "InvalidStateError");
1094
+ throw new DOMException("Failed to execute 'deleteRule' on 'CSSStyleSheet': Deleting a CSSNamespaceRule is not allowed when there is rules other than @import, @layer statement, or @namespace.", DOMException.INVALID_STATE_ERR);
1091
1095
  }
1092
1096
  }
1093
1097
  this.cssRules.splice(index, 1);
@@ -1131,9 +1135,9 @@ Object.defineProperty(CSSOM.CSSKeyframesRule.prototype, "cssText", {
1131
1135
  get: function() {
1132
1136
  var cssTexts = [];
1133
1137
  for (var i=0, length=this.cssRules.length; i < length; i++) {
1134
- cssTexts.push(" " + this.cssRules[i].cssText);
1138
+ cssTexts.push(this.cssRules[i].cssText);
1135
1139
  }
1136
- return "@" + (this._vendorPrefix || '') + "keyframes " + this.name + " { \n" + cssTexts.join("\n") + "\n}";
1140
+ return "@" + (this._vendorPrefix || '') + "keyframes " + this.name + (this.name && " ") + "{" + (cssTexts.length ? "\n " + cssTexts.join("\n ") : "") + "\n}";
1137
1141
  }
1138
1142
  });
1139
1143
 
@@ -1160,7 +1164,7 @@ CSSOM.CSSKeyframeRule.prototype.type = 8;
1160
1164
  // http://www.opensource.apple.com/source/WebCore/WebCore-955.66.1/css/WebKitCSSKeyframeRule.cpp
1161
1165
  Object.defineProperty(CSSOM.CSSKeyframeRule.prototype, "cssText", {
1162
1166
  get: function() {
1163
- return this.keyText + " {" + this.style.cssText + "} ";
1167
+ return this.keyText + " { " + this.style.cssText + " } ";
1164
1168
  }
1165
1169
  });
1166
1170
 
@@ -1244,7 +1248,7 @@ Object.defineProperty(CSSOM.CSSDocumentRule.prototype, "cssText", {
1244
1248
  for (var i=0, length=this.cssRules.length; i < length; i++) {
1245
1249
  cssTexts.push(this.cssRules[i].cssText);
1246
1250
  }
1247
- return "@-moz-document " + this.matcher.matcherText + " {" + cssTexts.join("") + "}";
1251
+ return "@-moz-document " + this.matcher.matcherText + " {" + (cssTexts.length ? "\n " + cssTexts.join("\n ") : "") + "\n}";
1248
1252
  }
1249
1253
  });
1250
1254
 
@@ -1642,7 +1646,7 @@ Object.defineProperties(CSSOM.CSSLayerBlockRule.prototype, {
1642
1646
  for (var i = 0, length = this.cssRules.length; i < length; i++) {
1643
1647
  cssTexts.push(this.cssRules[i].cssText);
1644
1648
  }
1645
- return "@layer " + this.name + (this.name && " ") + "{" + cssTexts.join("") + "}";
1649
+ return "@layer " + this.name + (this.name && " ") + "{" + (cssTexts.length ? "\n " + cssTexts.join("\n ") : "") + "\n}";
1646
1650
  },
1647
1651
  configurable: true,
1648
1652
  enumerable: true,
@@ -2571,9 +2575,13 @@ CSSOM.parse = function parse(token, errorHandler) {
2571
2575
  return match;
2572
2576
  });
2573
2577
  // In a nested selector, ensure each selector contains '&' at the beginning, except for selectors that already have '&' somewhere
2574
- styleRule.selectorText = parseAndSplitNestedSelectors(processedSelectorText).map(function(sel) {
2575
- return sel.indexOf('&') === -1 ? '& ' + sel : sel;
2576
- }).join(', ');
2578
+ if (parentRule.constructor.name !== "CSSStyleRule" && parentRule.parentRule === null) {
2579
+ styleRule.selectorText = processedSelectorText;
2580
+ } else {
2581
+ styleRule.selectorText = parseAndSplitNestedSelectors(processedSelectorText).map(function(sel) {
2582
+ return sel.indexOf('&') === -1 ? '& ' + sel : sel;
2583
+ }).join(', ');
2584
+ }
2577
2585
  styleRule.style.__starts = i - buffer.length;
2578
2586
  styleRule.parentRule = parentRule;
2579
2587
  nestedSelectorRule = styleRule;
@@ -37,7 +37,7 @@ Object.defineProperties(CSSOM.CSSContainerRule.prototype, {
37
37
  for (var i=0, length=this.cssRules.length; i < length; i++) {
38
38
  cssTexts.push(this.cssRules[i].cssText);
39
39
  }
40
- return "@container " + this.containerText + " {" + cssTexts.join("") + "}";
40
+ return "@container " + this.containerText + " {" + (cssTexts.length ? "\n " + cssTexts.join("\n ") : "") + "\n}";
41
41
  },
42
42
  configurable: true,
43
43
  enumerable: true
@@ -29,7 +29,7 @@ Object.defineProperty(CSSOM.CSSDocumentRule.prototype, "cssText", {
29
29
  for (var i=0, length=this.cssRules.length; i < length; i++) {
30
30
  cssTexts.push(this.cssRules[i].cssText);
31
31
  }
32
- return "@-moz-document " + this.matcher.matcherText + " {" + cssTexts.join("") + "}";
32
+ return "@-moz-document " + this.matcher.matcherText + " {" + (cssTexts.length ? "\n " + cssTexts.join("\n ") : "") + "\n}";
33
33
  }
34
34
  });
35
35
 
@@ -26,7 +26,7 @@ CSSOM.CSSFontFaceRule.prototype.type = 5;
26
26
  // http://www.opensource.apple.com/source/WebCore/WebCore-955.66.1/css/WebKitCSSFontFaceRule.cpp
27
27
  Object.defineProperty(CSSOM.CSSFontFaceRule.prototype, "cssText", {
28
28
  get: function() {
29
- return "@font-face {" + this.style.cssText + "}";
29
+ return "@font-face { " + this.style.cssText + " }";
30
30
  }
31
31
  });
32
32
 
@@ -27,7 +27,7 @@ Object.defineProperty(CSSOM.CSSHostRule.prototype, "cssText", {
27
27
  for (var i=0, length=this.cssRules.length; i < length; i++) {
28
28
  cssTexts.push(this.cssRules[i].cssText);
29
29
  }
30
- return "@host {" + cssTexts.join("") + "}";
30
+ return "@host {" + (cssTexts.length ? "\n " + cssTexts.join("\n ") : "") + "\n}";
31
31
  }
32
32
  });
33
33
 
@@ -27,7 +27,7 @@ CSSOM.CSSKeyframeRule.prototype.type = 8;
27
27
  // http://www.opensource.apple.com/source/WebCore/WebCore-955.66.1/css/WebKitCSSKeyframeRule.cpp
28
28
  Object.defineProperty(CSSOM.CSSKeyframeRule.prototype, "cssText", {
29
29
  get: function() {
30
- return this.keyText + " {" + this.style.cssText + "} ";
30
+ return this.keyText + " { " + this.style.cssText + " } ";
31
31
  }
32
32
  });
33
33
 
@@ -27,9 +27,9 @@ Object.defineProperty(CSSOM.CSSKeyframesRule.prototype, "cssText", {
27
27
  get: function() {
28
28
  var cssTexts = [];
29
29
  for (var i=0, length=this.cssRules.length; i < length; i++) {
30
- cssTexts.push(" " + this.cssRules[i].cssText);
30
+ cssTexts.push(this.cssRules[i].cssText);
31
31
  }
32
- return "@" + (this._vendorPrefix || '') + "keyframes " + this.name + " { \n" + cssTexts.join("\n") + "\n}";
32
+ return "@" + (this._vendorPrefix || '') + "keyframes " + this.name + (this.name && " ") + "{" + (cssTexts.length ? "\n " + cssTexts.join("\n ") : "") + "\n}";
33
33
  }
34
34
  });
35
35
 
@@ -26,7 +26,7 @@ Object.defineProperties(CSSOM.CSSLayerBlockRule.prototype, {
26
26
  for (var i = 0, length = this.cssRules.length; i < length; i++) {
27
27
  cssTexts.push(this.cssRules[i].cssText);
28
28
  }
29
- return "@layer " + this.name + (this.name && " ") + "{" + cssTexts.join("") + "}";
29
+ return "@layer " + this.name + (this.name && " ") + "{" + (cssTexts.length ? "\n " + cssTexts.join("\n ") : "") + "\n}";
30
30
  },
31
31
  configurable: true,
32
32
  enumerable: true,
@@ -40,7 +40,7 @@ Object.defineProperties(CSSOM.CSSMediaRule.prototype, {
40
40
  for (var i=0, length=this.cssRules.length; i < length; i++) {
41
41
  cssTexts.push(this.cssRules[i].cssText);
42
42
  }
43
- return "@media " + this.media.mediaText + " {" + cssTexts.join("") + "}";
43
+ return "@media " + this.media.mediaText + " {" + (cssTexts.length ? "\n " + cssTexts.join("\n ") : "") + "\n}";
44
44
  },
45
45
  configurable: true,
46
46
  enumerable: true
@@ -23,7 +23,7 @@ CSSOM.CSSNamespaceRule.prototype.type = 10;
23
23
 
24
24
  Object.defineProperty(CSSOM.CSSNamespaceRule.prototype, "cssText", {
25
25
  get: function() {
26
- return "@namespace" + (this.prefix && " " + this.prefix) + " url(" + this.namespaceURI + ");";
26
+ return "@namespace" + (this.prefix && " " + this.prefix) + " url(\"" + this.namespaceURI + "\");";
27
27
  },
28
28
  set: function(cssText) {
29
29
  // Reset prefix and namespaceURI
@@ -42,10 +42,10 @@ Object.defineProperty(CSSOM.CSSNamespaceRule.prototype, "cssText", {
42
42
  }
43
43
 
44
44
  // Regex to match valid namespace syntax:
45
- // 1. [optional prefix] url("...") or [optional prefix] url('...') or [optional prefix] url()
45
+ // 1. [optional prefix] url("...") or [optional prefix] url('...') or [optional prefix] url() or [optional prefix] url(unquoted)
46
46
  // 2. [optional prefix] "..." or [optional prefix] '...'
47
47
  // The prefix must be a valid CSS identifier (letters, digits, hyphens, underscores, starting with letter or underscore)
48
- var re = /^(?:([a-zA-Z_][a-zA-Z0-9_-]*)\s+)?(?:url\(\s*(?:(['"])(.*?)\2\s*)?\)|(['"])(.*?)\4)$/;
48
+ var re = /^(?:([a-zA-Z_][a-zA-Z0-9_-]*)\s+)?(?:url\(\s*(?:(['"])(.*?)\2\s*|([^)]*?))\s*\)|(['"])(.*?)\5)$/;
49
49
  var match = text.match(re);
50
50
 
51
51
  if (match) {
@@ -53,13 +53,17 @@ Object.defineProperty(CSSOM.CSSNamespaceRule.prototype, "cssText", {
53
53
  if (match[1]) {
54
54
  this.prefix = match[1];
55
55
  }
56
- // If url(...) form
56
+ // If url(...) form with quotes
57
57
  if (typeof match[3] !== "undefined") {
58
58
  this.namespaceURI = match[3];
59
59
  }
60
+ // If url(...) form without quotes
61
+ else if (typeof match[4] !== "undefined") {
62
+ this.namespaceURI = match[4].trim();
63
+ }
60
64
  // If quoted string form
61
- else if (typeof match[5] !== "undefined") {
62
- this.namespaceURI = match[5];
65
+ else if (typeof match[6] !== "undefined") {
66
+ this.namespaceURI = match[6];
63
67
  }
64
68
  } else {
65
69
  throw new DOMException("Invalid @namespace rule", "InvalidStateError");
@@ -27,7 +27,7 @@ Object.defineProperty(CSSOM.CSSStartingStyleRule.prototype, "cssText", {
27
27
  for (var i=0, length=this.cssRules.length; i < length; i++) {
28
28
  cssTexts.push(this.cssRules[i].cssText);
29
29
  }
30
- return "@starting-style {" + cssTexts.join("") + "}";
30
+ return "@starting-style {" + (cssTexts.length ? "\n " + cssTexts.join("\n ") : "") + "\n}";
31
31
  }
32
32
  });
33
33
 
@@ -34,7 +34,7 @@ Object.defineProperty(CSSOM.CSSStyleRule.prototype, "cssText", {
34
34
  valuesArr.push(this.cssRules.map(function(rule){ return rule.cssText }).join("\n "));
35
35
  values = valuesArr.join("\n ") + "\n}"
36
36
  } else {
37
- values = " {" + this.style.cssText + "}";
37
+ values = " { " + this.style.cssText + " }";
38
38
  }
39
39
  text = this.selectorText + values;
40
40
  } else {
@@ -49,9 +49,9 @@ CSSOM.CSSStyleSheet.prototype.insertRule = function(rule, index) {
49
49
  var ruleToParse = String(rule);
50
50
  var parsedSheet = CSSOM.parse(ruleToParse);
51
51
  if (parsedSheet.cssRules.length !== 1) {
52
- var domExceptionName = "SyntaxError";
52
+ var domExceptionName = DOMException.SYNTAX_ERR;
53
53
  if (ruleToParse.trimStart().startsWith('@namespace')) {
54
- domExceptionName = "InvalidStateError";
54
+ domExceptionName = DOMException.INVALID_STATE_ERR;
55
55
  }
56
56
  throw new DOMException("Failed to execute 'insertRule' on 'CSSStyleSheet': Failed to parse the rule '" + ruleToParse + "'.", domExceptionName);
57
57
  }
@@ -84,14 +84,14 @@ CSSOM.CSSStyleSheet.prototype.deleteRule = function(index) {
84
84
  index = 4294967296 + index;
85
85
  }
86
86
  if (index >= this.cssRules.length) {
87
- throw new DOMException("Failed to execute 'deleteRule' on 'CSSStyleSheet': The index provided (" + index + ") is larger than the maximum index (" + this.cssRules.length + ").", "IndexSizeError");
87
+ throw new DOMException("Failed to execute 'deleteRule' on 'CSSStyleSheet': The index provided (" + index + ") is larger than the maximum index (" + this.cssRules.length + ").", DOMException.INDEX_SIZE_ERR);
88
88
  }
89
89
  if (this.cssRules[index] && this.cssRules[index].constructor.name == "CSSNamespaceRule") {
90
90
  var shouldContinue = this.cssRules.every(function (rule) {
91
91
  return ['CSSImportRule','CSSLayerStatementRule','CSSNamespaceRule'].indexOf(rule.constructor.name) !== -1
92
92
  });
93
93
  if (!shouldContinue) {
94
- throw new DOMException("Failed to execute 'deleteRule' on 'CSSStyleSheet': Deleting a CSSNamespaceRule is not allowed when there is rules other than @import, @layer statement, or @namespace.", "InvalidStateError");
94
+ throw new DOMException("Failed to execute 'deleteRule' on 'CSSStyleSheet': Deleting a CSSNamespaceRule is not allowed when there is rules other than @import, @layer statement, or @namespace.", DOMException.INVALID_STATE_ERR);
95
95
  }
96
96
  }
97
97
  this.cssRules.splice(index, 1);
@@ -27,7 +27,7 @@ Object.defineProperty(CSSOM.CSSSupportsRule.prototype, "cssText", {
27
27
  cssTexts.push(this.cssRules[i].cssText);
28
28
  }
29
29
 
30
- return "@supports " + this.conditionText + " {" + cssTexts.join("") + "}";
30
+ return "@supports " + this.conditionText + " {" + (cssTexts.length ? "\n " + cssTexts.join("\n ") : "") + "\n}";
31
31
  }
32
32
  });
33
33
 
package/lib/parse.js CHANGED
@@ -900,9 +900,13 @@ CSSOM.parse = function parse(token, errorHandler) {
900
900
  return match;
901
901
  });
902
902
  // In a nested selector, ensure each selector contains '&' at the beginning, except for selectors that already have '&' somewhere
903
- styleRule.selectorText = parseAndSplitNestedSelectors(processedSelectorText).map(function(sel) {
904
- return sel.indexOf('&') === -1 ? '& ' + sel : sel;
905
- }).join(', ');
903
+ if (parentRule.constructor.name !== "CSSStyleRule" && parentRule.parentRule === null) {
904
+ styleRule.selectorText = processedSelectorText;
905
+ } else {
906
+ styleRule.selectorText = parseAndSplitNestedSelectors(processedSelectorText).map(function(sel) {
907
+ return sel.indexOf('&') === -1 ? '& ' + sel : sel;
908
+ }).join(', ');
909
+ }
906
910
  styleRule.style.__starts = i - buffer.length;
907
911
  styleRule.parentRule = parentRule;
908
912
  nestedSelectorRule = styleRule;
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "parser",
8
8
  "styleSheet"
9
9
  ],
10
- "version": "0.9.11",
10
+ "version": "0.9.13",
11
11
  "author": "Nikita Vasilyev <me@elv1s.ru>",
12
12
  "contributors": [
13
13
  "Acemir Sousa Mendes <acemirsm@gmail.com>"