From 179d9f336993e21ec47edbd85ba7bdbd17034af1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabi=C3=A1n=20Delgado?= Date: Tue, 9 Jun 2026 04:30:41 -0300 Subject: [PATCH] fix(js): implement CSS.supports() feature detection (#209) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(js): implement CSS.supports() feature detection CSS.supports() was a stub that always returned false. Sites that feature-detect CSS support (e.g. CSS.supports('display','flex')) treated the engine as lacking flexbox and redirected to their "unsupported browser" page, so the SPA never rendered. Implement both call signatures — supports(property, value) and supports(conditionText) — and return true for well-formed standard CSS declarations, matching modern browser behaviour. Malformed input (empty property/value, or a condition string with no colon) returns false. * Revert CSS.escape change, keep PR scoped to CSS.supports The escape stub was switched to String(s), which is unrelated to the feature-detection fix and still not a spec CSS.escape. Restore the original stub so this PR only touches CSS.supports. --------- Co-authored-by: SGavrl <277843151+SGavrl@users.noreply.github.com> --- crates/obscura-js/js/bootstrap.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/crates/obscura-js/js/bootstrap.js b/crates/obscura-js/js/bootstrap.js index 34b4278..1e82e01 100644 --- a/crates/obscura-js/js/bootstrap.js +++ b/crates/obscura-js/js/bootstrap.js @@ -4367,7 +4367,25 @@ globalThis.screenLeft = 0; globalThis.screenTop = 0; globalThis.pageXOffset = 0; globalThis.pageYOffset = 0; globalThis.scrollX = 0; globalThis.scrollY = 0; -globalThis.CSS = { supports(){return false;}, escape(s){return s;} }; +globalThis.CSS = { + supports(prop, value){ + try { + var p, v; + if (arguments.length >= 2) { p = String(prop).trim(); v = String(value).trim(); } + else { + var cond = String(prop).trim().replace(/^\(+|\)+$/g, "").trim(); + var idx = cond.indexOf(":"); + if (idx === -1) return false; + p = cond.slice(0, idx).trim(); v = cond.slice(idx + 1).trim(); + } + if (!p || !v) return false; + // The engine renders standard CSS; report it as supported so feature-gated + // SPAs don't bail to /unsupported. (Previous stub always returned false.) + return true; + } catch (e) { return false; } + }, + escape(s){ return s; } +}; globalThis.HTMLElement = Element; globalThis.HTMLDivElement = Element;