Skip to content

Commit 0f31381

Browse files
author
Bart Veneman
committed
ugh
1 parent e5a7ce1 commit 0f31381

File tree

8 files changed

+141
-53
lines changed

8 files changed

+141
-53
lines changed

package-lock.json

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
"scripts": {
2929
"test": "uvu",
3030
"lint": "oxlint",
31-
"build": "microbundle"
31+
"build": "microbundle",
32+
"check": "tsc"
3233
},
3334
"keywords": [
3435
"projectwallace",
@@ -52,6 +53,7 @@
5253
"css-tree": "^2.3.1"
5354
},
5455
"devDependencies": {
56+
"@types/css-tree": "^2.3.4",
5557
"microbundle": "^0.15.1",
5658
"oxlint": "^0.0.22",
5759
"uvu": "^0.5.6"

src/atrules/atrules.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { strEquals, startsWith, endsWith } from '../string-utils.js'
2+
// @ts-expect-error CSS Tree types are incomplete
23
import walk from 'css-tree/walker'
34
import {
45
Identifier,
@@ -16,7 +17,9 @@ import {
1617
* @returns true if declaratioNode is the given property: value, false otherwise
1718
*/
1819
function isPropertyValue(node, property, value) {
20+
if (node.value.type === 'Raw') return false
1921
let firstChild = node.value.children.first
22+
if (firstChild === null) return false
2023
return strEquals(property, node.property)
2124
&& firstChild.type === Identifier
2225
&& strEquals(value, firstChild.name)
@@ -72,26 +75,30 @@ export function isMediaBrowserhack(prelude) {
7275
if (node.type === MediaFeature) {
7376
if (value !== null && value.unit === '\\0') {
7477
returnValue = true
78+
// @ts-expect-error TS doesn't know about CSS Tree's walker breaking
7579
return this.break
7680
}
7781
if (strEquals('-moz-images-in-menus', name)
7882
|| strEquals('min--moz-device-pixel-ratio', name)
7983
|| strEquals('-ms-high-contrast', name)
8084
) {
8185
returnValue = true
86+
// @ts-expect-error TS doesn't know about CSS Tree's walker breaking
8287
return this.break
8388
}
8489
if (strEquals('min-resolution', name)
8590
&& strEquals('.001', value.value)
8691
&& strEquals('dpcm', value.unit)
8792
) {
8893
returnValue = true
94+
// @ts-expect-error TS doesn't know about CSS Tree's walker breaking
8995
return this.break
9096
}
9197
if (strEquals('-webkit-min-device-pixel-ratio', name)) {
9298
let val = value.value
9399
if ((strEquals('0', val) || strEquals('10000', val))) {
94100
returnValue = true
101+
// @ts-expect-error TS doesn't know about CSS Tree's walker breaking
95102
return this.break
96103
}
97104
}

0 commit comments

Comments
 (0)