fix(js): implement CSS.supports() feature detection (#209)
* 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 <[email protected]>
This commit is contained in:
1 parent
f64aca8064
commit
179d9f3369
1 file changed
+19
-1
Vendored
+19
-1
@@ -4367,7 +4367,25 @@ globalThis.screenLeft = 0; globalThis.screenTop = 0;
|
|||||||
globalThis.pageXOffset = 0; globalThis.pageYOffset = 0;
|
globalThis.pageXOffset = 0; globalThis.pageYOffset = 0;
|
||||||
globalThis.scrollX = 0; globalThis.scrollY = 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.HTMLElement = Element;
|
||||||
globalThis.HTMLDivElement = Element;
|
globalThis.HTMLDivElement = Element;
|
||||||
|
|||||||
Reference in new issue
Block a user