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:
1 parent
1826570927
commit
a16e8d4fe3
1 file changed
+9
Vendored
+9
@@ -1469,6 +1469,15 @@ class Element extends Node {
|
|||||||
const attr = this.getAttribute('value');
|
const attr = this.getAttribute('value');
|
||||||
return attr !== null ? attr : this.textContent;
|
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") || "";
|
return this.getAttribute("value") || "";
|
||||||
}
|
}
|
||||||
set value(v) {
|
set value(v) {
|
||||||
|
|||||||
Reference in new issue
Block a user