fix(chrome): emit every markup attribute and read checked and selected off the property

the dump emitted a fixed standard attribute set, so a spec reading data-cents or data-account-id saw undefined on the goja host and nothing at all in the trace. it now keys every attribute by the name the markup writes, derived keys overwriting. checked and selected come from the dom property rather than whatever a component left on the object, which is also what the page-side element handle now reports, so a ticked box reads as ticked instead of reporting its starting state forever.
This commit is contained in:
pj committed 2026-08-16 17:44:04 +05:30
1 parent de654334b0
commit 05c8523762
8 files changed
+605 -2

No files matched your search

+19
View File
@@ -547,12 +547,14 @@ function domElement(spec: {
attributes?: Record<string, string>;
labels?: string[];
text?: string;
checked?: boolean;
}): unknown {
const attributes = spec.attributes ?? {};
return {
tagName: spec.tag.toUpperCase(),
type: spec.tag === "input" ? "text" : "",
isContentEditable: false,
checked: spec.checked,
id: attributes.id ?? "",
className: attributes.class ?? "",
textContent: spec.text ?? "",
@@ -620,6 +622,23 @@ test("attrs keys data attributes by the name the markup writes", () => {
assert.deepEqual(handleOf(element).dataset, { txnCount: "3", accountId: "a-1" });
});
// docs/manual/spec-language.md lists `checked` on every element find returns,
// and HTML keeps that state in the DOM property: the markup attribute only
// records what the page started with. A handle reading the attribute reports a
// checkbox's starting state forever, so a property over "the box is ticked"
// holds on a page where nothing was ever ticked.
test("checked reads the live property, not the markup attribute", () => {
const ticked = domElement({ tag: "input", attributes: { id: "toggle-all" }, checked: true });
assert.equal(handleOf(ticked).checked, true);
const cleared = domElement({
tag: "input",
attributes: { id: "toggle-all", checked: "" },
checked: false,
});
assert.equal(handleOf(cleared).checked, false);
});
test("attrs carries every other attribute alongside tag and aria-label", () => {
const attrs = attrsOf(
domElement({ tag: "input", attributes: { id: "txn-note", placeholder: "What's this for?" } }),