From 117b58afdf246ee299472b929958c599fd350f74 Mon Sep 17 00:00:00 2001 From: Steve Repsher Date: Thu, 27 Jun 2024 16:20:36 +0000 Subject: [PATCH] Add fallback feature detection for Array.prototype.findLast --- src/html/_js_base.html.template | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/html/_js_base.html.template b/src/html/_js_base.html.template index 7c94ee3fa672..aaa55cbfdcf0 100644 --- a/src/html/_js_base.html.template +++ b/src/html/_js_base.html.template @@ -16,5 +16,9 @@ ) { _ls("/static/polyfills/webcomponents-bundle.js", true); } - var isModern = <%= modernRegex %>.test(navigator.userAgent); + // Modern browsers are detected primarily using the user agent string. + // A feature detection which roughly lines up with the modern targets is used + // as a fallback to guard against spoofs. It should be updated periodically. + var isModern = <%= modernRegex %>.test(navigator.userAgent) && + "findLast" in Array.prototype;