@miaskiewicz/turbo-dom 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.lock +7 -7
- package/Cargo.toml +7 -5
- package/README.md +13 -8
- package/package.json +1 -1
- package/pkg/package.json +2 -2
- package/pkg/turbo_dom_parser_bg.wasm +0 -0
- package/pkg-web/package.json +2 -2
- package/pkg-web/turbo_dom_parser_bg.wasm +0 -0
- package/src/runtime/cascade.mjs +70 -54
- package/src/runtime/css-shorthand.mjs +1217 -734
- package/src/runtime/custom-elements.mjs +8 -2
- package/src/runtime/dom.mjs +148 -95
- package/src/runtime/events.mjs +106 -85
- package/src/runtime/html-serialize.mjs +28 -24
- package/src/runtime/selectors.mjs +353 -237
- package/src/runtime/stubs.mjs +9 -6
- package/turbo-dom-parser.darwin-arm64.node +0 -0
- package/turbo-dom-parser.linux-arm64-gnu.node +0 -0
- package/turbo-dom-parser.linux-x64-gnu.node +0 -0
- package/turbo-dom-parser.linux-x64-musl.node +0 -0
- package/turbo-dom-parser.win32-x64-msvc.node +0 -0
package/src/runtime/stubs.mjs
CHANGED
|
@@ -55,6 +55,14 @@ export class Storage {
|
|
|
55
55
|
// is overridden — still stable for a given viewport. Unknown/feature-less queries
|
|
56
56
|
// stay honestly `false`.
|
|
57
57
|
const MQ_FEATURE = /\(\s*(min-width|max-width|min-height|max-height|orientation)\s*:\s*([^)]+?)\s*\)/g;
|
|
58
|
+
function evalMediaFeature(feat, val, W, H) {
|
|
59
|
+
if (feat === 'min-width') return W >= parseFloat(val);
|
|
60
|
+
if (feat === 'max-width') return W <= parseFloat(val);
|
|
61
|
+
if (feat === 'min-height') return H >= parseFloat(val);
|
|
62
|
+
if (feat === 'max-height') return H <= parseFloat(val);
|
|
63
|
+
// orientation: portrait iff height >= width (turbo-dom#138)
|
|
64
|
+
return val === (H >= W ? 'portrait' : 'landscape');
|
|
65
|
+
}
|
|
58
66
|
function evalMediaQuery(query, win) {
|
|
59
67
|
const W = (win && win.innerWidth) || 1024;
|
|
60
68
|
const H = (win && win.innerHeight) || 768;
|
|
@@ -63,12 +71,7 @@ function evalMediaQuery(query, win) {
|
|
|
63
71
|
MQ_FEATURE.lastIndex = 0;
|
|
64
72
|
while ((m = MQ_FEATURE.exec(q))) {
|
|
65
73
|
any = true;
|
|
66
|
-
|
|
67
|
-
if (feat === 'min-width') matched = matched && W >= parseFloat(val);
|
|
68
|
-
else if (feat === 'max-width') matched = matched && W <= parseFloat(val);
|
|
69
|
-
else if (feat === 'min-height') matched = matched && H >= parseFloat(val);
|
|
70
|
-
else if (feat === 'max-height') matched = matched && H <= parseFloat(val);
|
|
71
|
-
else matched = matched && val === (H >= W ? 'portrait' : 'landscape'); // orientation: portrait iff height >= width (turbo-dom#138)
|
|
74
|
+
matched = matched && evalMediaFeature(m[1], m[2].trim(), W, H);
|
|
72
75
|
}
|
|
73
76
|
return any && matched;
|
|
74
77
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|