Skip to content

Commit bc1acd1

Browse files
committed
MC-15022: HTML Content type does not render self closing html tags on storefront
Remove pass-by-reference in function
1 parent 25f798c commit bc1acd1

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

app/code/Magento/PageBuilder/Plugin/Filter/TemplatePlugin.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function afterFilter(\Magento\Framework\Filter\Template $subject, string
7171
// Process any HTML content types, they need to be decoded on the front-end
7272
if (strpos($result, 'data-content-type="html"') !== false) {
7373
$document = $this->getDomDocument($result);
74-
$this->convertEncodedHtmlContentTypesToPlaceholders($document, $uniqueNodeNameToDecodedOuterHtmlMap);
74+
$uniqueNodeNameToDecodedOuterHtmlMap = $this->generateDecodedHtmlPlaceholderMappingInDocument($document);
7575
}
7676

7777
// If a document was retrieved we've modified the output so need to retrieve it from within the document
@@ -155,11 +155,10 @@ function ($errorNumber, $errorString) {
155155
*
156156
* @param \DOMDocument $document
157157
* @param array $uniqueNodeNameToDecodedOuterHtmlMap
158+
* @return array - map of unique node name to decoded html
158159
*/
159-
private function convertEncodedHtmlContentTypesToPlaceholders(
160-
\DOMDocument $document,
161-
&$uniqueNodeNameToDecodedOuterHtmlMap = []
162-
): void {
160+
private function generateDecodedHtmlPlaceholderMappingInDocument(\DOMDocument $document): array
161+
{
163162
$xpath = new \DOMXPath($document);
164163

165164
// construct xpath query to fetch top-level ancestor html content type nodes
@@ -169,6 +168,8 @@ private function convertEncodedHtmlContentTypesToPlaceholders(
169168
'[not(ancestor::*[@data-content-type="html"])]'
170169
);
171170

171+
$uniqueNodeNameToDecodedOuterHtmlMap = [];
172+
172173
foreach ($htmlContentTypeNodes as $htmlContentTypeNode) {
173174
// Set decoded attribute on all encoded html content types so we don't double decode;
174175
$htmlContentTypeNode->setAttribute('data-decoded', 'true');
@@ -191,6 +192,8 @@ private function convertEncodedHtmlContentTypesToPlaceholders(
191192

192193
$uniqueNodeNameToDecodedOuterHtmlMap[$uniqueNodeName] = $decodedOuterHtml;
193194
}
195+
196+
return $uniqueNodeNameToDecodedOuterHtmlMap;
194197
}
195198

196199
/**

0 commit comments

Comments
 (0)