File tree Expand file tree Collapse file tree 3 files changed +25
-3
lines changed
tests/migrate/samples/is-not-where-has Expand file tree Collapse file tree 3 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -54,8 +54,16 @@ function migrate_css(state) {
54
54
code . startsWith ( ':is' ) ||
55
55
code . startsWith ( ':where' )
56
56
) {
57
- let parenthesis = 1 ;
58
57
let start = code . indexOf ( '(' ) + 1 ;
58
+ let is_global = false ;
59
+ const global_str = ':global' ;
60
+ const next_global = code . indexOf ( global_str ) ;
61
+ const str_between = code . substring ( start , next_global ) ;
62
+ if ( ! str_between . trim ( ) ) {
63
+ is_global = true ;
64
+ start += global_str . length ;
65
+ }
66
+ let parenthesis = 1 ;
59
67
let end = start ;
60
68
let char = code [ end ] ;
61
69
// find the closing parenthesis
@@ -66,8 +74,10 @@ function migrate_css(state) {
66
74
char = code [ end ] ;
67
75
}
68
76
if ( start && end ) {
69
- str . prependLeft ( starting + start , ':global(' ) ;
70
- str . appendRight ( starting + end - 1 , ')' ) ;
77
+ if ( ! is_global ) {
78
+ str . prependLeft ( starting + start , ':global(' ) ;
79
+ str . appendRight ( starting + end - 1 , ')' ) ;
80
+ }
71
81
starting += end - 1 ;
72
82
code = code . substring ( end - 1 ) ;
73
83
continue ;
Original file line number Diff line number Diff line change @@ -41,6 +41,12 @@ what if i'm talking about `:has()` in my blog?
41
41
div :where (.class:is (span:has (* > * ))){}
42
42
div :is (.class:is (span:is (:hover)), .x ){}
43
43
44
+ div :has ( :global (.class:is (span:where (:focus)))){}
45
+ div :not (:global (.class:is (span:where (:focus-within)))){}
46
+ div :is (:global (.class:is (span:is (:hover)))){}
47
+ div :where (:global (.class:is (span:has (* > * )))){}
48
+ div :is (:global (.class:is (span:is (:hover)), .x )){}
49
+
44
50
div {
45
51
p:has (& ){
46
52
Original file line number Diff line number Diff line change @@ -41,6 +41,12 @@ what if i'm talking about `:has()` in my blog?
41
41
div :where (:global (.class:is (span:has (* > * )))){}
42
42
div :is (:global (.class:is (span:is (:hover)), .x )){}
43
43
44
+ div :has ( :global (.class:is (span:where (:focus)))){}
45
+ div :not (:global (.class:is (span:where (:focus-within)))){}
46
+ div :is (:global (.class:is (span:is (:hover)))){}
47
+ div :where (:global (.class:is (span:has (* > * )))){}
48
+ div :is (:global (.class:is (span:is (:hover)), .x )){}
49
+
44
50
div {
45
51
p:has (:global (& )){
46
52
You can’t perform that action at this time.
0 commit comments