From 5b85646a9557c89d594c6a484f576fbdb0c38eb7 Mon Sep 17 00:00:00 2001 From: Eoghan Murray Date: Wed, 5 Jun 2024 10:59:50 +0100 Subject: [PATCH 1/3] No neg lookbehind (#1493) * Older versions of Safari 16 don't support lookbehind assertions - https://caniuse.com/js-regexp-lookbehind * Refactor to show the similarity between these two regexes * Apply formatting changes * Create no-neg-lookbehind.md --------- Co-authored-by: eoghanmurray --- .changeset/no-neg-lookbehind.md | 6 ++++++ .changeset/silent-plants-perform.md | 5 +++++ packages/rrweb-snapshot/src/css.ts | 18 ++++++++++++++---- 3 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 .changeset/no-neg-lookbehind.md create mode 100644 .changeset/silent-plants-perform.md diff --git a/.changeset/no-neg-lookbehind.md b/.changeset/no-neg-lookbehind.md new file mode 100644 index 0000000000..f152328ed3 --- /dev/null +++ b/.changeset/no-neg-lookbehind.md @@ -0,0 +1,6 @@ +--- +"rrweb-snapshot": patch +"rrweb": patch +--- + +Replay: Replace negative lookbehind in regexes from css parser as it causes issues with Safari 16 diff --git a/.changeset/silent-plants-perform.md b/.changeset/silent-plants-perform.md new file mode 100644 index 0000000000..1b234ec2a0 --- /dev/null +++ b/.changeset/silent-plants-perform.md @@ -0,0 +1,5 @@ +--- +"rrweb": patch +--- + +Return early for child same origin frames diff --git a/packages/rrweb-snapshot/src/css.ts b/packages/rrweb-snapshot/src/css.ts index 220e1a1fce..7aeb0d8a3d 100644 --- a/packages/rrweb-snapshot/src/css.ts +++ b/packages/rrweb-snapshot/src/css.ts @@ -424,6 +424,17 @@ export function parse(css: string, options: ParserOptions = {}): Stylesheet { * Parse selector. */ + // originally from https://github.com/NxtChg/pieces/blob/3eb39c8287a97632e9347a24f333d52d916bc816/js/css_parser/css_parse.js#L46C1-L47C1 + const selectorMatcher = new RegExp( + '^((' + + [ + /[^\\]"(?:\\"|[^"])*"/.source, // consume any quoted parts (checking that the double quote isn't itself escaped) + /[^\\]'(?:\\'|[^'])*'/.source, // same but for single quotes + '[^{]', + ].join('|') + + ')+)', + ); + function selector() { whitespace(); while (css[0] == '}') { @@ -432,8 +443,7 @@ export function parse(css: string, options: ParserOptions = {}): Stylesheet { whitespace(); } - // Use match logic from https://github.com/NxtChg/pieces/blob/3eb39c8287a97632e9347a24f333d52d916bc816/js/css_parser/css_parse.js#L46C1-L47C1 - const m = match(/^(((? Date: Tue, 6 Aug 2024 13:38:13 -0700 Subject: [PATCH 2/3] fix(session replay): add in no-negative lookback CSS change --- .changeset/no-neg-lookbehind.md | 4 ++-- .changeset/silent-plants-perform.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.changeset/no-neg-lookbehind.md b/.changeset/no-neg-lookbehind.md index f152328ed3..bcff1a5b38 100644 --- a/.changeset/no-neg-lookbehind.md +++ b/.changeset/no-neg-lookbehind.md @@ -1,6 +1,6 @@ --- -"rrweb-snapshot": patch -"rrweb": patch +"@amplitude/rrweb-snapshot": patch +"@amplitude/rrweb": patch --- Replay: Replace negative lookbehind in regexes from css parser as it causes issues with Safari 16 diff --git a/.changeset/silent-plants-perform.md b/.changeset/silent-plants-perform.md index 1b234ec2a0..fe85f99442 100644 --- a/.changeset/silent-plants-perform.md +++ b/.changeset/silent-plants-perform.md @@ -1,5 +1,5 @@ --- -"rrweb": patch +"@amplitude/rrweb": patch --- Return early for child same origin frames From 69fe681083ab62b0b2b908347441c04e425fba5b Mon Sep 17 00:00:00 2001 From: jxiwang Date: Tue, 6 Aug 2024 20:44:01 +0000 Subject: [PATCH 3/3] Apply formatting changes --- .changeset/no-neg-lookbehind.md | 4 ++-- .changeset/silent-plants-perform.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.changeset/no-neg-lookbehind.md b/.changeset/no-neg-lookbehind.md index bcff1a5b38..de5b3461bf 100644 --- a/.changeset/no-neg-lookbehind.md +++ b/.changeset/no-neg-lookbehind.md @@ -1,6 +1,6 @@ --- -"@amplitude/rrweb-snapshot": patch -"@amplitude/rrweb": patch +'@amplitude/rrweb-snapshot': patch +'@amplitude/rrweb': patch --- Replay: Replace negative lookbehind in regexes from css parser as it causes issues with Safari 16 diff --git a/.changeset/silent-plants-perform.md b/.changeset/silent-plants-perform.md index fe85f99442..be33b12930 100644 --- a/.changeset/silent-plants-perform.md +++ b/.changeset/silent-plants-perform.md @@ -1,5 +1,5 @@ --- -"@amplitude/rrweb": patch +'@amplitude/rrweb': patch --- Return early for child same origin frames