styled-components 6.3.5 → 6.3.6

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.
@@ -10,7 +10,7 @@
10
10
  'data-styled';
11
11
  var SC_ATTR_ACTIVE = 'active';
12
12
  var SC_ATTR_VERSION = 'data-styled-version';
13
- var SC_VERSION = "6.3.5";
13
+ var SC_VERSION = "6.3.6";
14
14
  var SPLITTER = '/*!sc*/\n';
15
15
  var IS_BROWSER = typeof window !== 'undefined' && typeof document !== 'undefined';
16
16
  /**
@@ -602,9 +602,11 @@
602
602
  var CLOSE_BRACE = 125; // }
603
603
  var SEMICOLON = 59; // ;
604
604
  var NEWLINE = 10; // \n
605
+ var OPEN_PAREN = 40; // (
606
+ var CLOSE_PAREN = 41; // )
605
607
  /**
606
608
  * Strips JS-style line comments (//) from CSS, handling comments anywhere
607
- * in the line while preserving strings and valid CSS.
609
+ * in the line while preserving strings, url() contents, and valid CSS.
608
610
  * Optimized with early bail and charCodeAt for performance.
609
611
  */
610
612
  function stripLineComments(css) {
@@ -616,6 +618,7 @@
616
618
  var start = 0;
617
619
  var i = 0;
618
620
  var inString = 0; // 0 = none, DOUBLE_QUOTE or SINGLE_QUOTE when in string
621
+ var urlDepth = 0; // Track nesting depth inside url()
619
622
  while (i < len) {
620
623
  var code = css.charCodeAt(i);
621
624
  // Track string state
@@ -635,8 +638,28 @@
635
638
  i++;
636
639
  continue;
637
640
  }
638
- // Check for line comment
639
- if (code === SLASH && css.charCodeAt(i + 1) === SLASH) {
641
+ // Track url() context - check for 'url(' (case insensitive via | 32)
642
+ if (code === OPEN_PAREN &&
643
+ i >= 3 &&
644
+ (css.charCodeAt(i - 1) | 32) === 108 && // l
645
+ (css.charCodeAt(i - 2) | 32) === 114 && // r
646
+ (css.charCodeAt(i - 3) | 32) === 117 // u
647
+ ) {
648
+ urlDepth = 1;
649
+ i++;
650
+ continue;
651
+ }
652
+ // Track nested parentheses inside url()
653
+ if (urlDepth > 0) {
654
+ if (code === CLOSE_PAREN)
655
+ urlDepth--;
656
+ else if (code === OPEN_PAREN)
657
+ urlDepth++;
658
+ i++;
659
+ continue;
660
+ }
661
+ // Check for line comment (only when not in url())
662
+ if (code === SLASH && i + 1 < len && css.charCodeAt(i + 1) === SLASH) {
640
663
  if (i > start)
641
664
  parts.push(css.substring(start, i));
642
665
  // Skip to end of line
@@ -648,7 +671,7 @@
648
671
  }
649
672
  i++;
650
673
  }
651
- // No comments found after indexOf check means // was in a string
674
+ // No comments found after indexOf check means // was in a string or url()
652
675
  if (start === 0)
653
676
  return css;
654
677
  if (start < len)