From a16e8d4fe3ef4562e810d7db87faa629f1cb1e23 Mon Sep 17 00:00:00 2001 From: SGavrl <277843151+SGavrl@users.noreply.github.com> Date: Tue, 30 Jun 2026 08:08:07 +0000 Subject: [PATCH] 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. --- crates/obscura-js/js/bootstrap.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crates/obscura-js/js/bootstrap.js b/crates/obscura-js/js/bootstrap.js index 61a3934..c1d53cd 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) {