Skip to content

The headless browser for AI agents and web scraping

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

SGavrla16e8d4fe3ef
diff --git a/crates/obscura-js/js/bootstrap.js b/crates/obscura-js/js/bootstrap.js
index 61a39343..c1d53cd7 100644
--- a/crates/obscura-js/js/bootstrap.js
+++ b/crates/obscura-js/js/bootstrap.js
@@ -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) {