File tree Expand file tree Collapse file tree 2 files changed +41
-7
lines changed
Expand file tree Collapse file tree 2 files changed +41
-7
lines changed Original file line number Diff line number Diff line change @@ -810,6 +810,39 @@ describe("media queries", () => {
810810 }
811811 } )
812812 ) . toEqual ( { a : 1 } ) ;
813+ expect (
814+ process ( {
815+ __mediaQueries : {
816+ "@media android" : [
817+ {
818+ inverse : false ,
819+ type : "android" ,
820+ expressions : [ ]
821+ }
822+ ] ,
823+ "@media not ios and (orientation: portrait)" : [
824+ {
825+ inverse : true ,
826+ type : "ios" ,
827+ expressions : [
828+ {
829+ feature : "orientation" ,
830+ modifier : undefined ,
831+ value : "portrait"
832+ }
833+ ]
834+ }
835+ ]
836+ } ,
837+ a : 1 ,
838+ "@media android" : {
839+ a : 2
840+ } ,
841+ "@media not ios and (orientation: portrait)" : {
842+ a : 4
843+ }
844+ } )
845+ ) . toEqual ( { a : 4 } ) ;
813846 expect (
814847 process ( {
815848 __mediaQueries : {
Original file line number Diff line number Diff line change @@ -30,13 +30,11 @@ function matchQuery(query, values) {
3030 // equal for a match.
3131 var typeMatch = query . type === "all" || values . type === query . type ;
3232
33- // Quit early when `type` doesn't match, but take "not" into account.
34- if ( ( typeMatch && inverse ) || ! ( typeMatch || inverse ) ) {
35- return false ;
36- }
37-
3833 if ( query . expressions . length === 0 ) {
39- return typeMatch || inverse ;
34+ // Quit early when `type` doesn't match, but take "not" into account.
35+ if ( ( typeMatch && inverse ) || ! ( typeMatch || inverse ) ) {
36+ return false ;
37+ }
4038 }
4139
4240 var expressionsMatch = query . expressions . every ( function ( expression ) {
@@ -94,7 +92,10 @@ function matchQuery(query, values) {
9492 }
9593 } ) ;
9694
97- return expressionsMatch || inverse ;
95+ if ( inverse ) {
96+ return ! ( typeMatch && expressionsMatch ) ;
97+ }
98+ return typeMatch && expressionsMatch ;
9899}
99100
100101// -- Utilities ----------------------------------------------------------------
You can’t perform that action at this time.
0 commit comments