@@ -485,46 +485,49 @@ export class CSSHelp {
485485 . map ( ( x ) => x . style ) ;
486486 }
487487
488- getStyle ( selector : string ) : ExtendedStyleDeclaration | null {
489- const style = this . _getStyleRules ( ) . find (
490- ( ele ) => ele ?. selectorText === selector
491- ) ?. style as ExtendedStyleDeclaration | undefined ;
492-
493- if ( ! style ) return null ;
494-
495- style . getPropVal = ( prop : string , strip = false ) =>
496- strip
497- ? style . getPropertyValue ( prop ) . replace ( / \s + / g, "" )
498- : style . getPropertyValue ( prop ) ;
499- return style ;
500- }
501- // A wrapper around getStyle for testing challenges where multiple CSS selectors are valid
488+ getStyle ( selector : string ) : ExtendedStyleDeclaration | null {
489+ const style = this . _getStyleRules ( ) . find (
490+ ( ele ) => ele ?. selectorText === selector ,
491+ ) ?. style as ExtendedStyleDeclaration | undefined ;
492+
493+ if ( ! style ) return null ;
494+
495+ style . getPropVal = ( prop : string , strip = false ) =>
496+ strip
497+ ? style . getPropertyValue ( prop ) . replace ( / \s + / g, "" )
498+ : style . getPropertyValue ( prop ) ;
499+ return style ;
500+ }
501+ // A wrapper around getStyle for testing challenges where multiple CSS selectors are valid
502+
503+ getStyleAny ( selectors : string [ ] ) : ExtendedStyleDeclaration | null {
504+ for ( const selector of selectors ) {
505+ // Skip wildcard unless explicitly requested
506+ if ( selector === "*" ) {
507+ const style = this . getStyle ( selector ) ;
508+ if ( style ) return style ;
509+ continue ;
510+ }
511+ // Exact match only
502512
503- getStyleAny ( selectors : string [ ] ) : ExtendedStyleDeclaration | null {
504- for ( const selector of selectors ) {
505- // Skip wildcard unless explicitly requested
506- if ( selector === "*" ) {
507513 const style = this . getStyle ( selector ) ;
508514 if ( style ) return style ;
509- continue ;
510515 }
511- // Exact match only
512- const style = this . getStyle ( selector ) ;
513- if ( style ) return style ;
516+
517+ return null ;
518+ }
519+
520+ getStyleRule ( selector : string ) : ExtendedStyleRule | null {
521+ const styleRule = this . _getStyleRules ( ) ?. find (
522+ ( ele ) => ele ?. selectorText === selector ,
523+ ) ;
524+ if ( ! styleRule ) return null ;
525+ return {
526+ ...styleRule ,
527+ isDeclaredAfter : ( targetSelector : string ) =>
528+ getIsDeclaredAfter ( styleRule ) ( targetSelector ) ,
529+ } ;
514530 }
515- return null ;
516- }
517- getStyleRule ( selector : string ) : ExtendedStyleRule | null {
518- const styleRule = this . _getStyleRules ( ) ?. find (
519- ( ele ) => ele ?. selectorText === selector
520- ) ;
521- if ( ! styleRule ) return null ;
522- return {
523- ...styleRule ,
524- isDeclaredAfter : ( targetSelector : string ) =>
525- getIsDeclaredAfter ( styleRule ) ( targetSelector ) ,
526- } ;
527- }
528531
529532 getCSSRules ( element ?: string ) : CSSRule [ ] {
530533 const styleSheet = this . getStyleSheet ( ) ;
0 commit comments