File tree 3 files changed +8
-1
lines changed
tests/runtime-runes/samples/media-query 3 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,8 @@ export class MediaQuery extends ReactiveValue {
42
42
constructor ( query , fallback ) {
43
43
let final_query =
44
44
parenthesis_regex . test ( query ) ||
45
- query . split ( ' ' ) . every ( ( keyword ) => non_parenthesized_keywords . has ( keyword ) )
45
+ // we need to use `some` here because technically this `window.matchMedia('random,screen')` still returns true
46
+ query . split ( / [ \s , ] + / ) . some ( ( keyword ) => non_parenthesized_keywords . has ( keyword . trim ( ) ) )
46
47
? query
47
48
: `(${ query } )` ;
48
49
const q = window . matchMedia ( final_query ) ;
Original file line number Diff line number Diff line change @@ -7,5 +7,8 @@ export default test({
7
7
expect ( window . matchMedia ) . toHaveBeenCalledWith ( '(min-width: 900px)' ) ;
8
8
expect ( window . matchMedia ) . toHaveBeenCalledWith ( 'screen' ) ;
9
9
expect ( window . matchMedia ) . toHaveBeenCalledWith ( 'not print' ) ;
10
+ expect ( window . matchMedia ) . toHaveBeenCalledWith ( 'screen,print' ) ;
11
+ expect ( window . matchMedia ) . toHaveBeenCalledWith ( 'screen, print' ) ;
12
+ expect ( window . matchMedia ) . toHaveBeenCalledWith ( 'screen, random' ) ;
10
13
}
11
14
} ) ;
Original file line number Diff line number Diff line change 5
5
const mq2 = new MediaQuery (" min-width: 900px" );
6
6
const mq3 = new MediaQuery (" screen" );
7
7
const mq4 = new MediaQuery (" not print" );
8
+ const mq5 = new MediaQuery (" screen,print" );
9
+ const mq6 = new MediaQuery (" screen, print" );
10
+ const mq7 = new MediaQuery (" screen, random" );
8
11
</script >
You can’t perform that action at this time.
0 commit comments