Skip to content

Commit

Permalink
fix: amplitude specific changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jxiwang committed Jul 30, 2024
1 parent 7eed14f commit 197a98a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .changeset/modern-doors-watch.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
'rrweb-snapshot': patch
'@amplitude/rrweb-snapshot': patch
---

better nested css selector splitting when commas or brackets happen to be in quoted text
14 changes: 12 additions & 2 deletions packages/rrweb-snapshot/src/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ export function parse(css: string, options: ParserOptions = {}): Stylesheet {
}

// Use match logic from https://github.com/NxtChg/pieces/blob/3eb39c8287a97632e9347a24f333d52d916bc816/js/css_parser/css_parse.js#L46C1-L47C1
const m = match(/^(("(?:\\"|[^"])*"|'(?:\\'|[^'])*'|[^{])+)/);
const m = match(/^(((?<!\\)"(?:\\"|[^"])*"|(?<!\\)'(?:\\'|[^'])*'|[^{])+)/);
if (!m) {
return;
}
Expand Down Expand Up @@ -864,7 +864,17 @@ export function parse(css: string, options: ParserOptions = {}): Stylesheet {
*/

function _compileAtrule(name: string) {
const re = new RegExp('^@' + name + '\\s*([^;]+);');
const re = new RegExp(
'^@' +
name +
'\\s*((?:' +
[
'(?<!\\\\)"(?:\\\\"|[^"])*"',
"(?<!\\\\)'(?:\\\\'|[^'])*'",
'[^;]',
].join('|') +
')+);',
);
return () => {
const pos = position();
const m = match(re);
Expand Down

0 comments on commit 197a98a

Please sign in to comment.