Skip to content

Commit f50a767

Browse files
committed
#558: Content Types Output Style Attribute Removal
- Minor Refactoring
1 parent b293714 commit f50a767

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

app/code/Magento/PageBuilder/Setup/Converters/PageBuilderStripStyles.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class PageBuilderStripStyles implements DataConverterInterface
2020
{
2121
const BODY_ID = 'html-body';
2222
const DATA_ATTRIBUTE = 'data-pb-style';
23+
const XPATH_SELECTOR = '//*[@data-content-type][@style]|//*[@data-content-type]/*[@style]';
2324

2425
/**
2526
* @var DOMDocument
@@ -74,7 +75,7 @@ public function convert($value)
7475
libxml_clear_errors();
7576

7677
$body = $document->documentElement->lastChild;
77-
$nodes = $xpath->query('//*[@data-content-type][@style]|//*[@data-content-type]/*[@style]'); // Query for Inline Styles
78+
$nodes = $xpath->query(self::XPATH_SELECTOR); // Query for Inline Styles
7879
$styleMap = [];
7980

8081
foreach ($nodes as $node) {

dev/tests/integration/testsuite/Magento/PageBuilder/Setup/Converters/PageBuilderStripStylesTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ public function testConvert(string $htmlString, int $expectedStyleTags)
5151
libxml_clear_errors();
5252

5353
// Check Inline Styles Were Removed
54-
$this->assertEquals(0, sizeof($xpathAfter->query('//*[@data-content-type][@style]|//*[@data-content-type]/*[@style]')));
54+
$this->assertEquals(0, count($xpathAfter->query(PageBuilderStripStyles::XPATH_SELECTOR)));
5555

5656
// Check Expected Internal Styles
57-
$this->assertEquals($expectedStyleTags, sizeof($xpathAfter->query('//style')));
57+
$this->assertEquals($expectedStyleTags, count($xpathAfter->query('//style')));
5858
}
5959

6060
/**

0 commit comments

Comments
 (0)