mirror of
https://github.com/BillyOutlast/posthog.git
synced 2026-02-04 03:01:23 +01:00
fix: nested css selector splitting (#21427)
This commit is contained in:
@@ -520,3 +520,51 @@ index e9a8ab2ba94093198f3dc42c9f6c4915f99cbc1d..182662fff8cca2eb4c63d956f0fce946
|
||||
}
|
||||
}
|
||||
applyMutation(d, isSync) {
|
||||
diff --git a/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js b/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js
|
||||
index 342e1df171368d312dc0372dace0c6b5a1eb9c61..e98368347aab6f22902e691e1909aa0333232140 100644
|
||||
--- a/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js
|
||||
+++ b/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js
|
||||
@@ -1254,16 +1254,40 @@ function parse(css, options = {}) {
|
||||
if (!m) {
|
||||
return;
|
||||
}
|
||||
- return trim(m[0])
|
||||
+ return splitRootSelectors(trim(m[0])
|
||||
.replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g, '')
|
||||
.replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g, (m) => {
|
||||
return m.replace(/,/g, '\u200C');
|
||||
- })
|
||||
- .split(/\s*(?![^(]*\)),\s*/)
|
||||
+ }))
|
||||
.map((s) => {
|
||||
return s.replace(/\u200C/g, ',');
|
||||
});
|
||||
}
|
||||
+ function splitRootSelectors(input) {
|
||||
+ let parts = [];
|
||||
+ let nestedLevel = 0;
|
||||
+ let currentPart = '';
|
||||
+
|
||||
+ for (let i = 0; i < input.length; i++) {
|
||||
+ const char = input[i];
|
||||
+ currentPart += char;
|
||||
+
|
||||
+ if (char === '(') {
|
||||
+ nestedLevel++;
|
||||
+ } else if (char === ')') {
|
||||
+ nestedLevel--;
|
||||
+ } else if (char === ',' && nestedLevel === 0) {
|
||||
+ parts.push(currentPart.slice(0, -1).trim());
|
||||
+ currentPart = '';
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (currentPart.trim() !== '') {
|
||||
+ parts.push(currentPart.trim());
|
||||
+ }
|
||||
+
|
||||
+ return parts;
|
||||
+ }
|
||||
function declaration() {
|
||||
const pos = position();
|
||||
const propMatch = match(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);
|
||||
|
||||
6
pnpm-lock.yaml
generated
6
pnpm-lock.yaml
generated
@@ -9,7 +9,7 @@ overrides:
|
||||
|
||||
patchedDependencies:
|
||||
rrweb@2.0.0-alpha.12:
|
||||
hash: 2rbzexnjhaf34oglgkdlfbhwde
|
||||
hash: t3xxecww6aodjl4qopwv6jdxmq
|
||||
path: patches/rrweb@2.0.0-alpha.12.patch
|
||||
|
||||
dependencies:
|
||||
@@ -327,7 +327,7 @@ dependencies:
|
||||
version: 1.5.1
|
||||
rrweb:
|
||||
specifier: 2.0.0-alpha.12
|
||||
version: 2.0.0-alpha.12(patch_hash=2rbzexnjhaf34oglgkdlfbhwde)
|
||||
version: 2.0.0-alpha.12(patch_hash=t3xxecww6aodjl4qopwv6jdxmq)
|
||||
sass:
|
||||
specifier: ^1.26.2
|
||||
version: 1.56.0
|
||||
@@ -19160,7 +19160,7 @@ packages:
|
||||
resolution: {integrity: sha512-i4sz9469dbsEGFiBzCkq+7I7M+imPeC3NrKgrrdJ2tXu9H+/eegNe4SrQgCsLBeSZHZDHU0o9L5rxTAiapWbGg==}
|
||||
dev: false
|
||||
|
||||
/rrweb@2.0.0-alpha.12(patch_hash=2rbzexnjhaf34oglgkdlfbhwde):
|
||||
/rrweb@2.0.0-alpha.12(patch_hash=t3xxecww6aodjl4qopwv6jdxmq):
|
||||
resolution: {integrity: sha512-lUGwBV7gmbwz1dIgzo9EEayIVyxoTIF6NBF6+Jctqs4Uy45QkyARtikpQlCUfxVCGTCQ0FOee9jeVYsG39oq1g==}
|
||||
dependencies:
|
||||
'@rrweb/types': 2.0.0-alpha.12
|
||||
|
||||
Reference in New Issue
Block a user