From 73bb9f1e210197a7cb9bf56ebf2692918e45ac09 Mon Sep 17 00:00:00 2001 From: Dhaval Parekh Date: Wed, 11 May 2022 22:50:33 +0530 Subject: [PATCH 1/4] Add 'data-amp-auto-lightbox-disable' attribute to HTML tag instead of body tag to disable auto-lightbox --- .../sanitizers/class-amp-auto-lightbox-disable-sanitizer.php | 2 +- tests/php/test-class-amp-auto-lightbox-disable-sanitizer.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/sanitizers/class-amp-auto-lightbox-disable-sanitizer.php b/includes/sanitizers/class-amp-auto-lightbox-disable-sanitizer.php index e4b87e95b95..61e503ebdf1 100644 --- a/includes/sanitizers/class-amp-auto-lightbox-disable-sanitizer.php +++ b/includes/sanitizers/class-amp-auto-lightbox-disable-sanitizer.php @@ -19,6 +19,6 @@ class AMP_Auto_Lightbox_Disable_Sanitizer extends AMP_Base_Sanitizer { * @return void */ public function sanitize() { - $this->dom->body->setAttributeNode( $this->dom->createAttribute( 'data-amp-auto-lightbox-disable' ) ); + $this->dom->html->setAttributeNode( $this->dom->createAttribute( 'data-amp-auto-lightbox-disable' ) ); } } diff --git a/tests/php/test-class-amp-auto-lightbox-disable-sanitizer.php b/tests/php/test-class-amp-auto-lightbox-disable-sanitizer.php index 898598bb27a..0aa069c1036 100644 --- a/tests/php/test-class-amp-auto-lightbox-disable-sanitizer.php +++ b/tests/php/test-class-amp-auto-lightbox-disable-sanitizer.php @@ -25,6 +25,6 @@ public function test_sanitize() { $sanitizer = new AMP_Auto_Lightbox_Disable_Sanitizer( $dom ); $sanitizer->sanitize(); - $this->assertTrue( $dom->body->hasAttribute( 'data-amp-auto-lightbox-disable' ) ); + $this->assertTrue( $dom->html->hasAttribute( 'data-amp-auto-lightbox-disable' ) ); } } From f14b172587bf78eb0479f053b9b1f72f04c6b2c1 Mon Sep 17 00:00:00 2001 From: Dhaval Parekh Date: Thu, 12 May 2022 00:34:25 +0530 Subject: [PATCH 2/4] Update test cases --- tests/php/test-class-amp-theme-support.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/php/test-class-amp-theme-support.php b/tests/php/test-class-amp-theme-support.php index dda5ffadf2a..da8c1de7776 100644 --- a/tests/php/test-class-amp-theme-support.php +++ b/tests/php/test-class-amp-theme-support.php @@ -1906,7 +1906,7 @@ public function test_prepare_response_standard_mode_non_amp( $with_amp_live_list $sanitized_html = AMP_Theme_Support::prepare_response( $original_html, [ ConfigurationArgument::ENABLE_OPTIMIZER => false ] ); - $this->assertStringContainsString( '', $sanitized_html, 'The AMP attribute is removed from the HTML element' ); + $this->assertStringContainsString( 'assertStringContainsString( '