Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d5d8c2d
prototype implementation
Archmonger Jun 19, 2025
1a1f3bb
Merge remote-tracking branch 'upstream/HEAD' into rewrite-event-to-ob…
Archmonger Nov 22, 2025
596c447
potential new design for event-to-object
Archmonger Dec 5, 2025
59c356c
new event-to-object tests
Archmonger Dec 5, 2025
33c5cef
refactor: change convert function to default export
Archmonger Dec 5, 2025
617ef91
add test for data-* attributes
Archmonger Dec 5, 2025
9039795
Update hatch for new test config
Archmonger Dec 5, 2025
258c86a
Add tests for 'on' checkbox properties
Archmonger Dec 5, 2025
941b692
Add test to ensure name property exists on inputs
Archmonger Dec 5, 2025
8c9ea0f
Add a test for toggleable checked property on checkboxes
Archmonger Dec 5, 2025
5e270c7
hatch fmt auto fixes
Archmonger Dec 5, 2025
6f5902b
fix python lint errors with new hatch version
Archmonger Dec 5, 2025
8559900
revert hatch version due to dependency resolution bugs
Archmonger Dec 6, 2025
061f5f5
try another pip install cmd
Archmonger Dec 6, 2025
e0ef341
try again
Archmonger Dec 6, 2025
be7ed36
handle file metadata in input fields
Archmonger Dec 6, 2025
930f1e2
Increase max depth
Archmonger Dec 6, 2025
ebd7759
handle infinite recursion
Archmonger Dec 6, 2025
76d18f9
Rewrite event-to-object package for improved event property handling
Archmonger Dec 6, 2025
d5f4ff5
Increase default maxDepth and refine key processing for DOM Nodes in …
Archmonger Dec 6, 2025
422dc8c
fix js lint
Archmonger Dec 6, 2025
5fa88b8
switch to hatch >=v1.16.2
Archmonger Dec 7, 2025
e5f4bd4
resolve co-pilot review comments
Archmonger Dec 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add test for data-* attributes
  • Loading branch information
Archmonger committed Dec 5, 2025
commit 617ef91846f0d511b4479af647c80a83143e2a72
17 changes: 17 additions & 0 deletions src/js/packages/event-to-object/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,23 @@ function classToObject(x: any, maxDepth: number): object {
result[key] = x[key];
}
}

// Explicitly include dataset if it exists (it might not be enumerable)
if (
x &&
typeof x === "object" &&
"dataset" in x &&
!Object.prototype.hasOwnProperty.call(result, "dataset")
) {
const dataset = x["dataset"];
if (!shouldIgnoreValue(dataset, "dataset", x)) {
const converted = deepCloneClass(dataset, maxDepth);
if (converted !== maxDepthSignal) {
result["dataset"] = converted;
}
}
}

return result;
}

Expand Down
33 changes: 33 additions & 0 deletions src/js/packages/event-to-object/tests/event-to-object.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,3 +372,36 @@ test("adds text of current selection", () => {
isTrusted: undefined,
});
});

test("includes data-* attributes in dataset", () => {
const div = document.createElement("div");
div.setAttribute("data-test-value", "123");
div.setAttribute("data-other", "foo");

const event = new window.Event("click");
Object.defineProperty(event, "target", {
value: div,
enumerable: true,
writable: true,
});
Object.defineProperty(event, "currentTarget", {
value: div,
enumerable: true,
writable: true,
});

checkEventConversion(event, {
target: {
dataset: {
testValue: "123",
other: "foo",
},
},
currentTarget: {
dataset: {
testValue: "123",
other: "foo",
},
},
});
});
2 changes: 1 addition & 1 deletion src/js/packages/event-to-object/tests/tooling/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { expect } from "bun:test";
import { Event } from "happy-dom";
// @ts-ignore
import lodash from "lodash";
import { convert } from "../../src/index";
import convert from "../../src/index";

export function checkEventConversion(
givenEvent: Event,
Expand Down