1
1
import { strEquals , startsWith , endsWith } from '../string-utils.js'
2
+ // @ts -expect-error CSS Tree types are incomplete
2
3
import walk from 'css-tree/walker'
3
4
import {
4
5
Identifier ,
@@ -16,7 +17,9 @@ import {
16
17
* @returns true if declaratioNode is the given property: value, false otherwise
17
18
*/
18
19
function isPropertyValue ( node , property , value ) {
20
+ if ( node . value . type === 'Raw' ) return false
19
21
let firstChild = node . value . children . first
22
+ if ( firstChild === null ) return false
20
23
return strEquals ( property , node . property )
21
24
&& firstChild . type === Identifier
22
25
&& strEquals ( value , firstChild . name )
@@ -72,26 +75,30 @@ export function isMediaBrowserhack(prelude) {
72
75
if ( node . type === MediaFeature ) {
73
76
if ( value !== null && value . unit === '\\0' ) {
74
77
returnValue = true
78
+ // @ts -expect-error TS doesn't know about CSS Tree's walker breaking
75
79
return this . break
76
80
}
77
81
if ( strEquals ( '-moz-images-in-menus' , name )
78
82
|| strEquals ( 'min--moz-device-pixel-ratio' , name )
79
83
|| strEquals ( '-ms-high-contrast' , name )
80
84
) {
81
85
returnValue = true
86
+ // @ts -expect-error TS doesn't know about CSS Tree's walker breaking
82
87
return this . break
83
88
}
84
89
if ( strEquals ( 'min-resolution' , name )
85
90
&& strEquals ( '.001' , value . value )
86
91
&& strEquals ( 'dpcm' , value . unit )
87
92
) {
88
93
returnValue = true
94
+ // @ts -expect-error TS doesn't know about CSS Tree's walker breaking
89
95
return this . break
90
96
}
91
97
if ( strEquals ( '-webkit-min-device-pixel-ratio' , name ) ) {
92
98
let val = value . value
93
99
if ( ( strEquals ( '0' , val ) || strEquals ( '10000' , val ) ) ) {
94
100
returnValue = true
101
+ // @ts -expect-error TS doesn't know about CSS Tree's walker breaking
95
102
return this . break
96
103
}
97
104
}
0 commit comments