octane 0.1.19 → 0.1.21

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.
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Clamp jsdom's stored scroll position to the range its layout metrics report.
3
+ * Browsers do this for programmatic scroll assignments, but jsdom can retain an
4
+ * out-of-range value because it does not perform layout. Dispatch the native
5
+ * event so components observe the normalized position through their public
6
+ * scroll boundary.
7
+ */
8
+ export declare function clampJsdomScrollTop(element: Element): void;
@@ -0,0 +1,14 @@
1
+ import { flushSync } from "./runtime.js";
2
+ function clampJsdomScrollTop(element) {
3
+ const scrollTop = Number.isFinite(element.scrollTop) ? element.scrollTop : 0;
4
+ const maxScrollTop = Math.max(0, element.scrollHeight - element.clientHeight);
5
+ const clampedScrollTop = Math.min(maxScrollTop, Math.max(0, scrollTop));
6
+ if (clampedScrollTop === element.scrollTop) return;
7
+ flushSync(() => {
8
+ element.scrollTop = clampedScrollTop;
9
+ element.dispatchEvent(new Event("scroll"));
10
+ });
11
+ }
12
+ export {
13
+ clampJsdomScrollTop
14
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "octane",
3
- "version": "0.1.19",
3
+ "version": "0.1.21",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -63,6 +63,10 @@
63
63
  "types": "./dist/static/index.d.ts",
64
64
  "default": "./dist/static/index.js"
65
65
  },
66
+ "./testing": {
67
+ "types": "./dist/testing.d.ts",
68
+ "default": "./dist/testing.js"
69
+ },
66
70
  "./constants": {
67
71
  "types": "./dist/constants.d.ts",
68
72
  "default": "./dist/constants.js"