File tree 3 files changed +81
-1
lines changed
3 files changed +81
-1
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " rrweb-cssom " : patch
3
+ ---
4
+
5
+ fix parsing errors for nested starting-style rules
Original file line number Diff line number Diff line change @@ -181,7 +181,7 @@ CSSOM.parse = function parse(token) {
181
181
break ;
182
182
} else if ( token . indexOf ( "@starting-style" , i ) === i ) {
183
183
state = "startingStyleRule-begin" ;
184
- i += "startingStyle " . length ;
184
+ i += "starting-style " . length ;
185
185
startingStyleRule = new CSSOM . CSSStartingStyleRule ( ) ;
186
186
startingStyleRule . __starts = i ;
187
187
buffer = "" ;
@@ -430,6 +430,7 @@ CSSOM.parse = function parse(token) {
430
430
parentRule . constructor . name === "CSSMediaRule"
431
431
|| parentRule . constructor . name === "CSSSupportsRule"
432
432
|| parentRule . constructor . name === "CSSContainerRule"
433
+ || parentRule . constructor . name === "CSSStartingStyleRule"
433
434
) {
434
435
prevScope = currentScope ;
435
436
currentScope = parentRule ;
Original file line number Diff line number Diff line change @@ -999,6 +999,80 @@ var TESTS = [
999
999
return result ;
1000
1000
} ) ( )
1001
1001
} ,
1002
+ {
1003
+ input : "@starting-style { @media screen { body { background: red; } } }" ,
1004
+ result : ( function ( ) {
1005
+ var result = {
1006
+ cssRules : [
1007
+ {
1008
+ cssRules : {
1009
+ 0 : {
1010
+ cssRules : {
1011
+ 0 : {
1012
+ parentRule : "../.." ,
1013
+ parentStyleSheet : "../../../../../.." ,
1014
+ selectorText : "body" ,
1015
+ style : {
1016
+ 0 : "background" ,
1017
+ length : 1 ,
1018
+ parentRule : ".." ,
1019
+ background : "red" ,
1020
+ } ,
1021
+ } ,
1022
+ } ,
1023
+ parentRule : null ,
1024
+ media : {
1025
+ 0 : "screen" ,
1026
+ length : 1
1027
+ }
1028
+ } ,
1029
+ } ,
1030
+ parentRule : null ,
1031
+ } ,
1032
+ ] ,
1033
+ parentStyleSheet : null ,
1034
+ } ;
1035
+ result . cssRules [ 0 ] . parentStyleSheet = result . cssRules [ 0 ] . cssRules [ 0 ] . parentStyleSheet = result ;
1036
+ return result ;
1037
+ } ) ( )
1038
+ } ,
1039
+ {
1040
+ input : "@media screen { @starting-style { body { background: red; } } }" ,
1041
+ result : ( function ( ) {
1042
+ var result = {
1043
+ cssRules : [
1044
+ {
1045
+ cssRules : {
1046
+ 0 : {
1047
+ cssRules : {
1048
+ 0 : {
1049
+ parentRule : "../.." ,
1050
+ parentStyleSheet : "../../../../../.." ,
1051
+ selectorText : "body" ,
1052
+ style : {
1053
+ 0 : "background" ,
1054
+ length : 1 ,
1055
+ parentRule : ".." ,
1056
+ background : "red" ,
1057
+ } ,
1058
+ } ,
1059
+ } ,
1060
+ parentRule : null ,
1061
+ } ,
1062
+ } ,
1063
+ parentRule : null ,
1064
+ media : {
1065
+ 0 : "screen" ,
1066
+ length : 1
1067
+ }
1068
+ } ,
1069
+ ] ,
1070
+ parentStyleSheet : null ,
1071
+ } ;
1072
+ result . cssRules [ 0 ] . parentStyleSheet = result . cssRules [ 0 ] . cssRules [ 0 ] . parentStyleSheet = result ;
1073
+ return result ;
1074
+ } ) ( )
1075
+ } ,
1002
1076
{
1003
1077
// Non-vendor prefixed @keyframes rule, from Twitter Bootstrap (progress-bars):
1004
1078
input : '@keyframes progress-bar-stripes {\n from { background-position: 0 0; }\n to { background-position: 40px 0; }\n}' ,
You can’t perform that action at this time.
0 commit comments