Skip to content

Commit 30ffcdb

Browse files
committed
#558: Content Types Output Style Attribute Removal
- Extending Tests - Refactoring - Removing `length` from `generateDataAttribute()` - Suppressing LibXML Errors
1 parent 12fe2e6 commit 30ffcdb

File tree

2 files changed

+103
-26
lines changed

2 files changed

+103
-26
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,9 @@ public function __construct(DOMDocument $domDocument)
3434
/**
3535
* Generates `mageUtils.uniqueid()` Naming Convention
3636
*
37-
* @param int $length
3837
* @return string
39-
* @todo Refactor `$length` Param
4038
*/
41-
private function generateDataAttribute(int $length = 7): string
39+
private function generateDataAttribute(): string
4240
{
4341
return strtoupper(uniqid());
4442
}
@@ -66,12 +64,14 @@ private function generateInternalStyles(array $styleMap): string
6664
*/
6765
public function convert($value)
6866
{
67+
libxml_use_internal_errors(true);
6968
$document = new DOMDocument();
7069
$document->loadHTML($value);
7170
$xpath = new DOMXPath($document);
71+
libxml_clear_errors();
7272

7373
$body = $document->documentElement->lastChild;
74-
$nodes = $xpath->query('//*[@style]'); // Query for Inline Styles
74+
$nodes = $xpath->query('//*[@data-content-type][@style]|//*[@data-content-type]/*[@style]'); // Query for Inline Styles
7575
$styleMap = [];
7676

7777
foreach ($nodes as $node) {

0 commit comments

Comments
 (0)