Skip to content

Commit

Permalink
Fixes #6948 -- rocket_lrc_processed_tags should be case insensitive (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
MathieuLamiot authored Sep 5, 2024
2 parents 4d7b54b + 2eb92d2 commit 554dc2a
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected function get_processed_tags() {
*
* @param array|string[] $tags Tags to be processed.
*/
return wpm_apply_filters_typed(
$tags = wpm_apply_filters_typed(
'array',
'rocket_lazy_render_content_processed_tags',
[
Expand All @@ -43,5 +43,10 @@ protected function get_processed_tags() {
'HEADER',
]
);

/**
* Convert tags to upper case here before
*/
return array_map( 'strtoupper', $tags );
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
namespace WP_Rocket\Tests\Integration\inc\Engine\Optimization\LazyRenderContent\Frontend\Filter;

use WP_Rocket\Engine\Optimization\LazyRenderContent\Frontend\Processor\Dom;
use WP_Rocket\Engine\Optimization\LazyRenderContent\Frontend\Processor\HelperTrait;
use WP_Rocket\Tests\Integration\TestCase;
use ReflectionClass;

/**
* Test class covering \WP_Rocket\Engine\Optimization\LazyRenderContent\Frontend\ProcessorHelperTrait::get_processed_tags()
*
* @group PerformanceHints
*/
class Test_lrcProcessedTagsFilter extends TestCase
{
public function testShouldReturnAsExpected() {
add_filter( 'rocket_lazy_render_content_processed_tags', function( $tags ) {
$tags[]= 'h2';
$tags[]= 'h1';
$tags[]= 'li';

return $tags;
});

$dom = new Dom();
$instance = new ReflectionClass( $dom );
$method = $instance->getMethod( 'get_processed_tags' );

$method->setAccessible(true);
$result = $method->invoke( $dom );

$expected = [ 'DIV', 'MAIN', 'FOOTER', 'SECTION', 'ARTICLE', 'HEADER', 'H2', 'H1', 'LI' ];

$this->assertSame( $expected, $result );
}
}

0 comments on commit 554dc2a

Please sign in to comment.