Skip to content

Commit

Permalink
Merge pull request #3034 from ampproject/add/amp-script-tree-solidifi…
Browse files Browse the repository at this point in the history
…cation

Prevent tree shaking any CSS selectors based on the descendants of amp-script elements
  • Loading branch information
westonruter authored Aug 14, 2019
2 parents ccd10ee + ba5e663 commit 0303912
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions includes/sanitizers/class-amp-style-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class AMP_Style_Sanitizer extends AMP_Base_Sanitizer {
'amp-live-list',
'[submit-error]',
'[submit-success]',
'amp-script',
],
'should_locate_sources' => false,
'parsed_cache_variant' => null,
Expand Down
3 changes: 3 additions & 0 deletions tests/php/test-amp-style-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,12 @@ public function get_link_and_style_test_data() {
'<style amp-custom>.dead-list li .highlighted, amp-live-list li .highlighted { background: yellow }</style>',
'<style amp-custom>article.missing amp-live-list li .highlighted { background: yellow }</style>',
'<style amp-custom>body amp-list .portland { color:blue; }</style>',
'<style amp-custom>amp-script .loaded { color:brown; }</style>',
'</head><body>',
'<form method="post" action-xhr="https://example.com/subscribe" target="_top"><div submit-success><template type="amp-mustache"><b>Thanks</b>, {{name}}}</template></div></form>',
'<amp-live-list id="my-live-list" data-poll-interval="15000" data-max-items-per-page="20"><button update on="tap:my-live-list.update">You have updates!</button><ul items><li id="live-list-2-item-2" data-sort-time="1464281932879">Hello</li></ul></amp-live-list>',
'<amp-list width="auto" height="100" layout="fixed-height" src="https://ampproject-b5f4c.firebaseapp.com/examples/data/amp-list-urls.json"> <template type="amp-mustache"> <div class="url-entry"> <a href="{{url}}" class="{{class}}">{{title}}</a> </div> </template> </amp-list>',
'<amp-script src="https://example.com/populate/server/time">The current server time is <time class="loading">loading...</time>.</amp-script>',
'</body></html>',
]
),
Expand All @@ -351,6 +353,7 @@ public function get_link_and_style_test_data() {
'amp-live-list li .highlighted{background:yellow}',
'',
'body amp-list .portland{color:blue}',
'amp-script .loaded{color:brown}',
],
[],
],
Expand Down

0 comments on commit 0303912

Please sign in to comment.