Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/brown-onions-relate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"rrweb-cssom": patch
---

fix parsing errors for nested starting-style rules
3 changes: 2 additions & 1 deletion lib/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ CSSOM.parse = function parse(token) {
break;
} else if (token.indexOf("@starting-style", i) === i) {
state = "startingStyleRule-begin";
i += "startingStyle".length;
i += "starting-style".length;
startingStyleRule = new CSSOM.CSSStartingStyleRule();
startingStyleRule.__starts = i;
buffer = "";
Expand Down Expand Up @@ -430,6 +430,7 @@ CSSOM.parse = function parse(token) {
parentRule.constructor.name === "CSSMediaRule"
|| parentRule.constructor.name === "CSSSupportsRule"
|| parentRule.constructor.name === "CSSContainerRule"
|| parentRule.constructor.name === "CSSStartingStyleRule"
) {
prevScope = currentScope;
currentScope = parentRule;
Expand Down
74 changes: 74 additions & 0 deletions spec/parse.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,80 @@ var TESTS = [
return result;
})()
},
{
input: "@starting-style { @media screen { body { background: red; } } }",
result: (function() {
var result = {
cssRules: [
{
cssRules: {
0: {
cssRules: {
0: {
parentRule: "../..",
parentStyleSheet: "../../../../../..",
selectorText: "body",
style: {
0: "background",
length: 1,
parentRule: "..",
background: "red",
},
},
},
parentRule: null,
media: {
0: "screen",
length: 1
}
},
},
parentRule: null,
},
],
parentStyleSheet: null,
};
result.cssRules[0].parentStyleSheet = result.cssRules[0].cssRules[0].parentStyleSheet = result;
return result;
})()
},
{
input: "@media screen { @starting-style { body { background: red; } } }",
result: (function() {
var result = {
cssRules: [
{
cssRules: {
0: {
cssRules: {
0: {
parentRule: "../..",
parentStyleSheet: "../../../../../..",
selectorText: "body",
style: {
0: "background",
length: 1,
parentRule: "..",
background: "red",
},
},
},
parentRule: null,
},
},
parentRule: null,
media: {
0: "screen",
length: 1
}
},
],
parentStyleSheet: null,
};
result.cssRules[0].parentStyleSheet = result.cssRules[0].cssRules[0].parentStyleSheet = result;
return result;
})()
},
{
// Non-vendor prefixed @keyframes rule, from Twitter Bootstrap (progress-bars):
input: '@keyframes progress-bar-stripes {\n from { background-position: 0 0; }\n to { background-position: 40px 0; }\n}',
Expand Down