fix(js): default checkbox and radio value to "on"

A checkbox or radio input with no value attribute returns "on" in a real
browser; obscura returned the empty string. Page scripts that read
input.value to build form submissions (and browser-environment checks)
saw the wrong default. An explicit value attribute still wins.

Refs #335.
This commit is contained in:
SGavrl committed 2026-06-30 15:18:21 +00:00
1 parent 1826570927
commit a16e8d4fe3
1 file changed
+9
+9
View File
@@ -1469,6 +1469,15 @@ class Element extends Node {
const attr = this.getAttribute('value');
return attr !== null ? attr : this.textContent;
}
if (tag === 'input') {
const itype = (this.getAttribute('type') || '').toLowerCase();
if (itype === 'checkbox' || itype === 'radio') {
// A checkbox/radio with no value attribute defaults to "on" in a real
// browser, not the empty string.
const attr = this.getAttribute('value');
return attr !== null ? attr : 'on';
}
}
return this.getAttribute("value") || "";
}
set value(v) {