{"action":"created","issue":{"url":"https://api.github.com/repos/Automattic/amp-wp/issues/1226","repository_url":"https://api.github.com/repos/Automattic/amp-wp","labels_url":"https://api.github.com/repos/Automattic/amp-wp/issues/1226/labels{/name}","comments_url":"https://api.github.com/repos/Automattic/amp-wp/issues/1226/comments","events_url":"https://api.github.com/repos/Automattic/amp-wp/issues/1226/events","html_url":"https://github.com/Automattic/amp-wp/pull/1226","id":335603923,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk3MjYzMzc1","number":1226,"title":"Add AMP_Script_Sanitizer to replace noscript elements with their contents","user":{"login":"westonruter","id":134745,"node_id":"MDQ6VXNlcjEzNDc0NQ==","avatar_url":"https://avatars2.githubusercontent.com/u/134745?v=4","gravatar_id":"","url":"https://api.github.com/users/westonruter","html_url":"https://github.com/westonruter","followers_url":"https://api.github.com/users/westonruter/followers","following_url":"https://api.github.com/users/westonruter/following{/other_user}","gists_url":"https://api.github.com/users/westonruter/gists{/gist_id}","starred_url":"https://api.github.com/users/westonruter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/westonruter/subscriptions","organizations_url":"https://api.github.com/users/westonruter/orgs","repos_url":"https://api.github.com/users/westonruter/repos","events_url":"https://api.github.com/users/westonruter/events{/privacy}","received_events_url":"https://api.github.com/users/westonruter/received_events","type":"User","site_admin":false},"labels":[{"id":969379437,"node_id":"MDU6TGFiZWw5NjkzNzk0Mzc=","url":"https://api.github.com/repos/Automattic/amp-wp/labels/beta","name":"beta","color":"1d0977","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/Automattic/amp-wp/milestones/7","html_url":"https://github.com/Automattic/amp-wp/milestone/7","labels_url":"https://api.github.com/repos/Automattic/amp-wp/milestones/7/labels","id":3171161,"node_id":"MDk6TWlsZXN0b25lMzE3MTE2MQ==","number":7,"title":"v1.0","description":"","creator":{"login":"ThierryA","id":3581402,"node_id":"MDQ6VXNlcjM1ODE0MDI=","avatar_url":"https://avatars3.githubusercontent.com/u/3581402?v=4","gravatar_id":"","url":"https://api.github.com/users/ThierryA","html_url":"https://github.com/ThierryA","followers_url":"https://api.github.com/users/ThierryA/followers","following_url":"https://api.github.com/users/ThierryA/following{/other_user}","gists_url":"https://api.github.com/users/ThierryA/gists{/gist_id}","starred_url":"https://api.github.com/users/ThierryA/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ThierryA/subscriptions","organizations_url":"https://api.github.com/users/ThierryA/orgs","repos_url":"https://api.github.com/users/ThierryA/repos","events_url":"https://api.github.com/users/ThierryA/events{/privacy}","received_events_url":"https://api.github.com/users/ThierryA/received_events","type":"User","site_admin":false},"open_issues":13,"closed_issues":100,"state":"open","created_at":"2018-03-08T09:34:26Z","updated_at":"2018-06-25T23:30:39Z","due_on":null,"closed_at":null},"comments":2,"created_at":"2018-06-25T23:30:39Z","updated_at":"2018-06-26T00:20:32Z","closed_at":null,"author_association":"COLLABORATOR","pull_request":{"url":"https://api.github.com/repos/Automattic/amp-wp/pulls/1226","html_url":"https://github.com/Automattic/amp-wp/pull/1226","diff_url":"https://github.com/Automattic/amp-wp/pull/1226.diff","patch_url":"https://github.com/Automattic/amp-wp/pull/1226.patch"},"body":"As noted in [Implementing Interactivity](https://github.com/Automattic/amp-wp/wiki/Implementing-Interactivity):\r\n\r\n> the baseline experience after enabling AMP on an existing theme is that it largely behaves as if JavaScript is disabled in the user's browser. Many themes and plugins already have fallbacks in case JavaScript is not available so that will serve them well in AMP. Therefore, most of the work entailed is to progressively enhance a theme for AMP to restore features that were lost during this graceful no-JS degradation to AMP\r\n\r\nNevertheless, this is not totally true at present: the plugin's postprocessor does not currently do any transformation of `noscript` elements meaning that the no-JS fallbacks will be not be successfully used in AMP pages. \r\n\r\nSo this PR ensures that that a non-AMP document like:\r\n\r\n```html\r\n<script>document.write('Scripts!')</script><noscript><em>No scripts!</em></noscript>\r\n```\r\n\r\nWill get served in AMP as:\r\n\r\n```html\r\n<!--noscript--><em>No scripts!</em><!--/noscript-->\r\n```\r\n\r\nThus it encourages the use of no-JS fallbacks for the baseline AMP experience as well as for visitors who have JS turned off in their browsers.\r\n\r\nThis will be further built upon in #1213 and #1032 with more intelligence about whether to promote the `noscript` element's contents or rather to convert a companion `script` to an AMP equivalent."},"comment":{"url":"https://api.github.com/repos/Automattic/amp-wp/issues/comments/400136055","html_url":"https://github.com/Automattic/amp-wp/pull/1226#issuecomment-400136055","issue_url":"https://api.github.com/repos/Automattic/amp-wp/issues/1226","id":400136055,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMDEzNjA1NQ==","user":{"login":"westonruter","id":134745,"node_id":"MDQ6VXNlcjEzNDc0NQ==","avatar_url":"https://avatars2.githubusercontent.com/u/134745?v=4","gravatar_id":"","url":"https://api.github.com/users/westonruter","html_url":"https://github.com/westonruter","followers_url":"https://api.github.com/users/westonruter/followers","following_url":"https://api.github.com/users/westonruter/following{/other_user}","gists_url":"https://api.github.com/users/westonruter/gists{/gist_id}","starred_url":"https://api.github.com/users/westonruter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/westonruter/subscriptions","organizations_url":"https://api.github.com/users/westonruter/orgs","repos_url":"https://api.github.com/users/westonruter/repos","events_url":"https://api.github.com/users/westonruter/events{/privacy}","received_events_url":"https://api.github.com/users/westonruter/received_events","type":"User","site_admin":false},"created_at":"2018-06-26T00:20:32Z","updated_at":"2018-06-26T00:20:32Z","author_association":"COLLABORATOR","body":"Force-pushed a tweak. Maybe there was a caching problem. The test is failing as if these lines are not present:\r\n\r\n```diff\r\n--- a/tests/test-amp-script-sanitizer.php\r\n+++ b/tests/test-amp-script-sanitizer.php\r\n@@ -38,8 +38,6 @@ class AMP_Script_Sanitizer_Test extends WP_UnitTestCase {\r\n \t */\r\n \tpublic function test_noscript_promotion( $source, $expected = null ) {\r\n \t\t$dom       = AMP_DOM_Utils::get_dom_from_content( $source );\r\n-\t\t$sanitizer = new AMP_Script_Sanitizer( $dom );\r\n-\t\t$sanitizer->sanitize();\r\n \t\t$whitelist_sanitizer = new AMP_Tag_And_Attribute_Sanitizer( $dom );\r\n \t\t$whitelist_sanitizer->sanitize();\r\n \t\t$content = AMP_DOM_Utils::get_content_from_dom( $dom );\r\n```"}}
{"actor":{"display_login":"westonruter"}}