From 153ed4031fdf097a70aacc2884e35c15a69e5927 Mon Sep 17 00:00:00 2001 From: Tim Fischbach Date: Mon, 8 Jan 2024 07:32:35 +0100 Subject: [PATCH] Prevent invalid-regular expression syntax error in Safari < 16.4 PR #177 added regular expressions to parse CSSNumericValue objects using lookbehind. Safari only supports lookbehind starting from version 16.4 [1]. In earlier versions loading the polyfill causes an error of the form: ``` SyntaxError: Invalid regular expression: invalid group specifier name ``` Compile RegExp on demand to ensure the polyfill can be loaded without errors. Since the relevant functions are only called initially when parsing options, the performance overhead appears limited. [1] https://caniuse.com/js-regexp-lookbehind --- src/proxy-cssom.js | 6 +++--- src/scroll-timeline-base.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/proxy-cssom.js b/src/proxy-cssom.js index 04c39d49..e2d69301 100644 --- a/src/proxy-cssom.js +++ b/src/proxy-cssom.js @@ -97,7 +97,7 @@ export function installCSSOM() { */ function parseCSSMultiplication(str) { let values = []; - const tokens = str.split(/(? { if (str.trim() === 'auto') { return 'auto';