@@ -142,45 +142,23 @@ function transformSelector(
142142 if ( ! res ) {
143143 return
144144 }
145-
146145 let parentSelector = res [ 1 ]
147- let curSelector = res [ 2 ]
148- // 恢复 ::part(xxx)
149- if ( parentSelector . includes ( '-_part__' ) ) {
150- parentSelector = parentSelector . replace ( / - _ p a r t _ _ ( .+ ) _ - / g, '::part($1)' )
151- }
152- if ( curSelector . includes ( '-_part__' ) ) {
153- curSelector = curSelector . replace ( / - _ p a r t _ _ ( .+ ) _ - / g, '::part($1)' )
154- }
146+ let curSelector = res [ 2 ] . substring ( 1 )
155147 // .a.b => a.b
156- const dotIndex = curSelector . lastIndexOf ( '.' )
157- if ( dotIndex > 0 ) {
158- parentSelector += curSelector . substring ( 0 , dotIndex )
159- curSelector = curSelector . substring ( dotIndex )
160- }
161- if ( curSelector . indexOf ( '.' ) === 0 ) {
162- curSelector = curSelector . substring ( 1 )
148+ const dotIndex = curSelector . indexOf ( '.' )
149+ if ( dotIndex > - 1 ) {
150+ parentSelector += curSelector . substring ( dotIndex )
151+ curSelector = curSelector . substring ( 0 , dotIndex )
163152 }
164153
165- const pseudoElementIndex = curSelector . indexOf ( '::' )
166- if ( pseudoElementIndex > - 1 ) {
167- // TODO 目前仅支持::part作为最后个Selector Component使用
168- // ::part(xxx).xxx 是否支持?
169- // ::part(xxx):active 保留原样?
170- const partSelector = curSelector . slice ( pseudoElementIndex )
171- const baseSelector = curSelector . substring ( 0 , pseudoElementIndex )
172- curSelector = partSelector
173- parentSelector += baseSelector
174- } else {
175- const pseudoIndex = curSelector . indexOf ( ':' )
176- if ( pseudoIndex > - 1 ) {
177- const pseudoClass = curSelector . slice ( pseudoIndex )
178- curSelector = curSelector . slice ( 0 , pseudoIndex )
179- Object . keys ( body ) . forEach ( function ( name ) {
180- body [ name + pseudoClass ] = body [ name ]
181- delete body [ name ]
182- } )
183- }
154+ const pseudoIndex = curSelector . indexOf ( ':' )
155+ if ( pseudoIndex > - 1 ) {
156+ const pseudoClass = curSelector . slice ( pseudoIndex )
157+ curSelector = curSelector . slice ( 0 , pseudoIndex )
158+ Object . keys ( body ) . forEach ( function ( name ) {
159+ body [ name + pseudoClass ] = body [ name ]
160+ delete body [ name ]
161+ } )
184162 }
185163 transition ( curSelector , body , context )
186164 if ( ! Object . keys ( body ) . length ) {
0 commit comments