@@ -658,8 +658,8 @@ export class ShadowCss {
658
658
659
659
private _scopeSelector ( selector : string , scopeSelector : string , hostSelector : string ) : string {
660
660
return selector
661
- . split ( ',' )
662
- . map ( ( part ) => part . trim ( ) . split ( _shadowDeepSelectors ) )
661
+ . split ( / ? , ? / )
662
+ . map ( ( part ) => part . split ( _shadowDeepSelectors ) )
663
663
. map ( ( deepParts ) => {
664
664
const [ shallowPart , ...otherParts ] = deepParts ;
665
665
const applyScope = ( shallowPart : string ) => {
@@ -727,10 +727,10 @@ export class ShadowCss {
727
727
let scopedP = p . trim ( ) ;
728
728
729
729
if ( ! scopedP ) {
730
- return '' ;
730
+ return p ;
731
731
}
732
732
733
- if ( p . indexOf ( _polyfillHostNoCombinator ) > - 1 ) {
733
+ if ( p . includes ( _polyfillHostNoCombinator ) ) {
734
734
scopedP = this . _applySimpleSelectorScope ( p , scopeSelector , hostSelector ) ;
735
735
} else {
736
736
// remove :host since it should be unnecessary
@@ -765,13 +765,18 @@ export class ShadowCss {
765
765
// - `tag:host` -> `tag[h]` (this is to avoid breaking legacy apps, should not match anything)
766
766
// - `tag :host` -> `tag [h]` (`tag` is not scoped because it's considered part of a
767
767
// `:host-context(tag)`)
768
- const hasHost = selector . indexOf ( _polyfillHostNoCombinator ) > - 1 ;
768
+ const hasHost = selector . includes ( _polyfillHostNoCombinator ) ;
769
769
// Only scope parts after the first `-shadowcsshost-no-combinator` when it is present
770
770
let shouldScope = ! hasHost ;
771
771
772
772
while ( ( res = sep . exec ( selector ) ) !== null ) {
773
773
const separator = res [ 1 ] ;
774
- const part = selector . slice ( startIndex , res . index ) . trim ( ) ;
774
+ // Do not trim the selector, as otherwise this will break sourcemaps
775
+ // when they are defined on multiple lines
776
+ // Example:
777
+ // div,
778
+ // p { color: red}
779
+ const part = selector . slice ( startIndex , res . index ) ;
775
780
776
781
// A space following an escaped hex value and followed by another hex character
777
782
// (ie: ".\fc ber" for ".über") is not a separator between 2 selectors
@@ -781,14 +786,14 @@ export class ShadowCss {
781
786
continue ;
782
787
}
783
788
784
- shouldScope = shouldScope || part . indexOf ( _polyfillHostNoCombinator ) > - 1 ;
789
+ shouldScope = shouldScope || part . includes ( _polyfillHostNoCombinator ) ;
785
790
const scopedPart = shouldScope ? _scopeSelectorPart ( part ) : part ;
786
791
scopedSelector += `${ scopedPart } ${ separator } ` ;
787
792
startIndex = sep . lastIndex ;
788
793
}
789
794
790
795
const part = selector . substring ( startIndex ) ;
791
- shouldScope = shouldScope || part . indexOf ( _polyfillHostNoCombinator ) > - 1 ;
796
+ shouldScope = shouldScope || part . includes ( _polyfillHostNoCombinator ) ;
792
797
scopedSelector += shouldScope ? _scopeSelectorPart ( part ) : part ;
793
798
794
799
// replace the placeholders with their original values
0 commit comments