@@ -72,7 +72,7 @@ public function get_body_style_attribute_data() {
7272 '<span style="color: #00ff00;">This is green.</span> ' ,
7373 '<span data-amp-original-style="color: #00ff00;" class="amp-wp-bb01159">This is green.</span> ' ,
7474 [
75- ':root: not(#_):not(#_):not(#_):not(#_):not( #_) .amp-wp-bb01159 {color:#0f0} ' ,
75+ '.amp-wp-bb01159: not(#_#_#_#_ #_){color:#0f0} ' ,
7676 ],
7777 ],
7878
@@ -86,81 +86,81 @@ public function get_body_style_attribute_data() {
8686 '<span style="color : #00ff00">This is green.</span> ' ,
8787 '<span data-amp-original-style="color : #00ff00" class="amp-wp-0837823">This is green.</span> ' ,
8888 [
89- ':root: not(#_):not(#_):not(#_):not(#_):not( #_) .amp-wp-0837823 {color:#0f0} ' ,
89+ '.amp-wp-0837823: not(#_#_#_#_ #_){color:#0f0} ' ,
9090 ],
9191 ],
9292
9393 'span_two_styles_reversed ' => [
9494 '<span style="color: #00ff00; background-color: #000;">This is green.</span> ' ,
9595 '<span data-amp-original-style="color: #00ff00; background-color: #000;" class="amp-wp-be0c539">This is green.</span> ' ,
9696 [
97- ':root: not(#_):not(#_):not(#_):not(#_):not( #_) .amp-wp-be0c539 {color:#0f0;background-color:#000} ' ,
97+ '.amp-wp-be0c539: not(#_#_#_#_ #_){color:#0f0;background-color:#000} ' ,
9898 ],
9999 ],
100100
101101 'span_display_none ' => [
102102 '<span style="display: none;">Kses-banned properties are allowed since Kses will have already applied if user does not have unfiltered_html.</span> ' ,
103103 '<span data-amp-original-style="display: none;" class="amp-wp-224b51a">Kses-banned properties are allowed since Kses will have already applied if user does not have unfiltered_html.</span> ' ,
104104 [
105- ':root: not(#_):not(#_):not(#_):not(#_):not( #_) .amp-wp-224b51a {display:none} ' ,
105+ '.amp-wp-224b51a: not(#_#_#_#_ #_){display:none} ' ,
106106 ],
107107 ],
108108
109109 '!important_is_ok ' => [
110110 '<span style="padding:1px; margin: 2px !important; outline: 3px;">!important is converted.</span> ' ,
111111 '<span data-amp-original-style="padding:1px; margin: 2px !important; outline: 3px;" class="amp-wp-6a75598">!important is converted.</span> ' ,
112112 [
113- ':root: not(#_):not(#_):not(#_):not(#_):not( #_) .amp-wp-6a75598 {padding:1px;outline:3px}:root: not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not( #_) .amp-wp-6a75598 {margin:2px} ' ,
113+ '.amp-wp-6a75598: not(#_#_#_#_ #_){padding:1px;outline:3px}.amp-wp-6a75598: not(#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_ #_){margin:2px} ' ,
114114 ],
115115 ],
116116
117117 '!important_with_spaces_also_converted ' => [
118118 '<span style="color: red ! important;">!important is converted.</span> ' ,
119119 '<span data-amp-original-style="color: red ! important;" class="amp-wp-952600b">!important is converted.</span> ' ,
120120 [
121- ':root: not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not( #_) .amp-wp-952600b {color:red} ' ,
121+ '.amp-wp-952600b: not(#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_ #_){color:red} ' ,
122122 ],
123123 ],
124124
125125 '!important_multiple_is_converted ' => [
126126 '<span style="color: red !important; background: blue!important;">!important is converted.</span> ' ,
127127 '<span data-amp-original-style="color: red !important; background: blue!important;" class="amp-wp-1e2bfaa">!important is converted.</span> ' ,
128128 [
129- ':root: not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not( #_) .amp-wp-1e2bfaa {color:red;background:blue} ' ,
129+ '.amp-wp-1e2bfaa: not(#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_ #_){color:red;background:blue} ' ,
130130 ],
131131 ],
132132
133133 '!important_takes_precedence_over_inline ' => [
134134 '<header id="header" style="display: none;"><h1>This is the header.</h1></header><style>#header { display: block !important;width: 100%;background: #fff; } ' ,
135135 '<header id="header" data-amp-original-style="display: none;" class="amp-wp-224b51a"><h1>This is the header.</h1></header> ' ,
136136 [
137- '#header{width:100%;background:#fff}:root: not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not( #_) #header {display:block} ' ,
138- ':root: not(#_):not(#_):not(#_):not(#_):not( #_) .amp-wp-224b51a {display:none} ' ,
137+ '#header{width:100%;background:#fff}#header: not(#_#_#_#_#_#_ #_){display:block} ' ,
138+ '.amp-wp-224b51a: not(#_#_#_#_ #_){display:none} ' ,
139139 ],
140140 ],
141141
142142 'two_nodes ' => [
143143 '<span style="color: #00ff00;"><span style="color: #ff0000;">This is red.</span></span> ' ,
144144 '<span data-amp-original-style="color: #00ff00;" class="amp-wp-bb01159"><span data-amp-original-style="color: #ff0000;" class="amp-wp-cc68ddc">This is red.</span></span> ' ,
145145 [
146- ':root: not(#_):not(#_):not(#_):not(#_):not( #_) .amp-wp-bb01159 {color:#0f0} ' ,
147- ':root: not(#_):not(#_):not(#_):not(#_):not( #_) .amp-wp-cc68ddc {color:#f00} ' ,
146+ '.amp-wp-bb01159: not(#_#_#_#_ #_){color:#0f0} ' ,
147+ '.amp-wp-cc68ddc: not(#_#_#_#_ #_){color:#f00} ' ,
148148 ],
149149 ],
150150
151151 'existing_class_attribute ' => [
152152 '<figure class="alignleft" style="background: #000"></figure> ' ,
153153 '<figure class="alignleft amp-wp-2864855" data-amp-original-style="background: #000"></figure> ' ,
154154 [
155- ':root: not(#_):not(#_):not(#_):not(#_):not( #_) .amp-wp-2864855 {background:#000} ' ,
155+ '.amp-wp-2864855: not(#_#_#_#_ #_){background:#000} ' ,
156156 ],
157157 ],
158158
159159 'inline_style_element_with_multiple_rules_containing_selectors_is_removed ' => [
160160 '<style>div > span { font-weight:bold !important; font-style: italic; } @media screen and ( max-width: 640px ) { div > span { font-weight:normal !important; font-style: normal; } }</style><div><span>bold!</span></div> ' ,
161161 '<div><span>bold!</span></div> ' ,
162162 [
163- 'div > span{font-style:italic}:root: not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not( #_) div > span {font-weight:bold}@media screen and ( max-width: 640px ){div > span{font-style:normal}:root: not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not( #_) div > span {font-weight:normal}} ' ,
163+ 'div > span{font-style:italic}div > span: not(#_#_#_#_#_#_#_ #_){font-weight:bold}@media screen and ( max-width: 640px ){div > span{font-style:normal}div > span: not(#_#_#_#_#_#_#_ #_){font-weight:normal}} ' ,
164164 ],
165165 ],
166166
@@ -178,7 +178,7 @@ public function get_body_style_attribute_data() {
178178 '<span style="color:brown; @media screen { color:green }">invalid @-rule omitted.</span> ' ,
179179 '<span data-amp-original-style="color:brown; @media screen { color:green }" class="amp-wp-481af57">invalid @-rule omitted.</span> ' ,
180180 [
181- ':root: not(#_):not(#_):not(#_):not(#_):not( #_) .amp-wp-481af57 {color:brown} ' ,
181+ '.amp-wp-481af57: not(#_#_#_#_ #_){color:brown} ' ,
182182 ],
183183 [],
184184 ],
@@ -247,9 +247,9 @@ public function get_body_style_attribute_data() {
247247 '<style>#child {color:red !important} #parent #child {color:pink !important} .foo { color:blue !important; } #me .foo { color: green !important; }</style><div id="parent"><span id="child" class="foo bar baz">one</span><span style="color: yellow;">two</span><span style="color: purple !important;">three</span></div><div id="me"><span class="foo"></span></div> ' ,
248248 '<div id="parent"><span id="child" class="foo bar baz">one</span><span data-amp-original-style="color: yellow;" class="amp-wp-64b4fd4">two</span><span data-amp-original-style="color: purple !important;" class="amp-wp-ab79d9e">three</span></div><div id="me"><span class="foo"></span></div> ' ,
249249 [
250- ':root: not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not( #_) #child {color:red}:root: not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not( #_) #parent #child {color:pink}:root: not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not( #_) .foo {color:blue}:root: not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not( #_) #me .foo {color:green} ' ,
251- ':root: not(#_):not(#_):not(#_):not(#_):not( #_) .amp-wp-64b4fd4 {color:yellow} ' ,
252- ':root: not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not( #_) .amp-wp-ab79d9e {color:purple} ' ,
250+ '#child: not(#_#_#_#_#_#_ #_){color:red}#parent #child: not(#_#_#_#_#_#_#_ #_){color:pink}.foo: not(#_#_#_#_#_#_ #_){color:blue}#me .foo: not(#_#_#_#_#_#_#_ #_){color:green} ' ,
251+ '.amp-wp-64b4fd4: not(#_#_#_#_ #_){color:yellow} ' ,
252+ '.amp-wp-ab79d9e: not(#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_ #_){color:purple} ' ,
253253 ],
254254 ],
255255
@@ -265,15 +265,15 @@ public function get_body_style_attribute_data() {
265265 '<table><colgroup><col width="253"/></colgroup></table> ' ,
266266 '<table><colgroup><col data-amp-original-style="width: 253px" class="amp-wp-cbcb5c2"></colgroup></table> ' ,
267267 [
268- ':root: not(#_):not(#_):not(#_):not(#_):not( #_) .amp-wp-cbcb5c2 {width:253px} ' ,
268+ '.amp-wp-cbcb5c2: not(#_#_#_#_ #_){width:253px} ' ,
269269 ],
270270 ],
271271
272272 'col_with_percent_width_attribute ' => [
273273 '<table><colgroup><col width="50%"/></colgroup></table> ' ,
274274 '<table><colgroup><col data-amp-original-style="width: 50%" class="amp-wp-cd7753e"></colgroup></table> ' ,
275275 [
276- ':root: not(#_):not(#_):not(#_):not(#_):not( #_) .amp-wp-cd7753e {width:50%} ' ,
276+ '.amp-wp-cd7753e: not(#_#_#_#_ #_){width:50%} ' ,
277277 ],
278278 ],
279279
@@ -288,7 +288,7 @@ public function get_body_style_attribute_data() {
288288 '<table><colgroup><col width="50" style="background-color: red; width: 60px"/></colgroup></table> ' ,
289289 '<table><colgroup><col data-amp-original-style="width: 50px;background-color: red; width: 60px" class="amp-wp-c8aa9e9"></colgroup></table> ' ,
290290 [
291- ':root: not(#_):not(#_):not(#_):not(#_):not( #_) .amp-wp-c8aa9e9 {width:50px;width:60px;background-color:red} ' ,
291+ '.amp-wp-c8aa9e9: not(#_#_#_#_ #_){width:50px;width:60px;background-color:red} ' ,
292292 ],
293293 ],
294294
@@ -352,8 +352,8 @@ public function get_body_style_attribute_data() {
352352 ' ,
353353 [
354354 '.custom-population{color:red} ' ,
355- ':root: not(#_):not(#_):not(#_):not(#_):not( #_) .amp-wp-f2a1aff {color:blue} ' ,
356- ':root: not(#_):not(#_):not(#_):not(#_):not( #_) .amp-wp-d4ea4c7 {outline:solid 1px black} ' ,
355+ '.amp-wp-f2a1aff: not(#_#_#_#_ #_){color:blue} ' ,
356+ '.amp-wp-d4ea4c7: not(#_#_#_#_ #_){outline:solid 1px black} ' ,
357357 ],
358358 ],
359359 'with_mustache_template_script ' => [
@@ -386,8 +386,8 @@ public function get_body_style_attribute_data() {
386386 ' ,
387387 [
388388 '.custom-population{color:red} ' ,
389- ':root: not(#_):not(#_):not(#_):not(#_):not( #_) .amp-wp-f2a1aff {color:blue} ' ,
390- ':root: not(#_):not(#_):not(#_):not(#_):not( #_) .amp-wp-d4ea4c7 {outline:solid 1px black} ' ,
389+ '.amp-wp-f2a1aff: not(#_#_#_#_ #_){color:blue} ' ,
390+ '.amp-wp-d4ea4c7: not(#_#_#_#_ #_){outline:solid 1px black} ' ,
391391 ],
392392 ],
393393 'with_internal_amp_selectors_and_class_names ' => [
@@ -531,9 +531,9 @@ public function get_link_and_style_test_data() {
531531 'multiple_amp_custom_and_other_styles ' => [
532532 '<html amp><head><meta charset="utf-8"><style amp-custom>b {color:red !important}</style><style amp-custom>i {color:blue}</style><style type="text/css">u {color:green; text-decoration: underline !important}</style></head><body><style>s {color:yellow} /* So !important! */</style><b>1</b><i>i</i><u>u</u><s>s</s></body></html> ' ,
533533 [
534- ':root: not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not( #_) b {color:red} ' ,
534+ 'b: not(#_#_#_#_#_#_#_ #_){color:red} ' ,
535535 'i{color:blue} ' ,
536- 'u{color:green}:root: not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not( #_) u {text-decoration:underline} ' ,
536+ 'u{color:green}u: not(#_#_#_#_#_#_#_ #_){text-decoration:underline} ' ,
537537 's{color:yellow} ' ,
538538 ],
539539 [],
@@ -547,7 +547,7 @@ public function get_link_and_style_test_data() {
547547 'strong.before-dashicon ' ,
548548 '.dashicons-dashboard:before ' ,
549549 'strong.after-dashicon ' ,
550- ':root: not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not( #_) s {color:yellow} ' ,
550+ 's: not(#_#_#_#_#_#_#_ #_){color:yellow} ' ,
551551 ],
552552 [],
553553 ],
@@ -575,8 +575,8 @@ public function get_link_and_style_test_data() {
575575 'style_on_root_element ' => [
576576 '<html amp style="color:red;"><head><meta charset="utf-8"><style amp-custom>html { background-color: blue !important; }</style></head><body>Hi</body></html> ' ,
577577 [
578- 'html:not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not( #_){background-color:blue} ' ,
579- ':root: not(#_):not(#_):not(#_):not(#_):not( #_) .amp-wp-10b06ba {color:red} ' ,
578+ 'html:not(#_#_#_#_#_#_#_ #_){background-color:blue} ' ,
579+ '.amp-wp-10b06ba: not(#_#_#_#_ #_){color:red} ' ,
580580 ],
581581 [],
582582 ],
@@ -1099,10 +1099,10 @@ public function get_data_to_test_transform_important_qualifiers_arg() {
10991099 true , // should_sanitize
11001100 $ html ,
11011101 [
1102- ':root: not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not( #_) .foo {color:red} ' ,
1103- ':root: not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not( #_) .foo[data-amp-original-style*="blue"] {outline:solid 2px green} ' ,
1104- ':root: not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not(#_):not( #_) .amp-wp-9605c4d {background:blue} ' ,
1105- ':root: not(#_):not(#_):not(#_):not(#_):not( #_) .amp-wp-32bb249 {background:red} ' ,
1102+ '.foo: not(#_#_#_#_#_#_ #_){color:red} ' ,
1103+ '.foo[data-amp-original-style*="blue"]: not(#_#_#_#_#_#_ #_){outline:solid 2px green} ' ,
1104+ '.amp-wp-9605c4d: not(#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_#_ #_){background:blue} ' ,
1105+ '.amp-wp-32bb249: not(#_#_#_#_ #_){background:red} ' ,
11061106 ],
11071107 '<style amp-custom> ' ,
11081108 '
0 commit comments