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 <eoghanmurray@users.noreply.github.com>
This commit is contained in:
6
.changeset/no-neg-lookbehind.md
Normal file
6
.changeset/no-neg-lookbehind.md
Normal file
@@ -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
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
'rrweb': patch
|
"rrweb": patch
|
||||||
---
|
---
|
||||||
|
|
||||||
Return early for child same origin frames
|
Return early for child same origin frames
|
||||||
|
|||||||
@@ -424,6 +424,17 @@ export function parse(css: string, options: ParserOptions = {}): Stylesheet {
|
|||||||
* Parse selector.
|
* 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() {
|
function selector() {
|
||||||
whitespace();
|
whitespace();
|
||||||
while (css[0] == '}') {
|
while (css[0] == '}') {
|
||||||
@@ -432,8 +443,7 @@ export function parse(css: string, options: ParserOptions = {}): Stylesheet {
|
|||||||
whitespace();
|
whitespace();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use match logic from https://github.com/NxtChg/pieces/blob/3eb39c8287a97632e9347a24f333d52d916bc816/js/css_parser/css_parse.js#L46C1-L47C1
|
const m = match(selectorMatcher);
|
||||||
const m = match(/^(((?<!\\)"(?:\\"|[^"])*"|(?<!\\)'(?:\\'|[^'])*'|[^{])+)/);
|
|
||||||
if (!m) {
|
if (!m) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -869,8 +879,8 @@ export function parse(css: string, options: ParserOptions = {}): Stylesheet {
|
|||||||
name +
|
name +
|
||||||
'\\s*((?:' +
|
'\\s*((?:' +
|
||||||
[
|
[
|
||||||
'(?<!\\\\)"(?:\\\\"|[^"])*"',
|
/[^\\]"(?:\\"|[^"])*"/.source, // consume any quoted parts (checking that the double quote isn't itself escaped)
|
||||||
"(?<!\\\\)'(?:\\\\'|[^'])*'",
|
/[^\\]'(?:\\'|[^'])*'/.source, // same but for single quotes
|
||||||
'[^;]',
|
'[^;]',
|
||||||
].join('|') +
|
].join('|') +
|
||||||
')+);',
|
')+);',
|
||||||
|
|||||||
Reference in New Issue
Block a user