@@ -71,7 +71,7 @@ public function afterFilter(\Magento\Framework\Filter\Template $subject, string
71
71
// Process any HTML content types, they need to be decoded on the front-end
72
72
if (strpos ($ result , 'data-content-type="html" ' ) !== false ) {
73
73
$ document = $ this ->getDomDocument ($ result );
74
- $ this ->convertEncodedHtmlContentTypesToPlaceholders ($ document, $ uniqueNodeNameToDecodedOuterHtmlMap );
74
+ $ uniqueNodeNameToDecodedOuterHtmlMap = $ this ->generateDecodedHtmlPlaceholderMappingInDocument ($ document );
75
75
}
76
76
77
77
// 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) {
155
155
*
156
156
* @param \DOMDocument $document
157
157
* @param array $uniqueNodeNameToDecodedOuterHtmlMap
158
+ * @return array - map of unique node name to decoded html
158
159
*/
159
- private function convertEncodedHtmlContentTypesToPlaceholders (
160
- \DOMDocument $ document ,
161
- &$ uniqueNodeNameToDecodedOuterHtmlMap = []
162
- ): void {
160
+ private function generateDecodedHtmlPlaceholderMappingInDocument (\DOMDocument $ document ): array
161
+ {
163
162
$ xpath = new \DOMXPath ($ document );
164
163
165
164
// construct xpath query to fetch top-level ancestor html content type nodes
@@ -169,6 +168,8 @@ private function convertEncodedHtmlContentTypesToPlaceholders(
169
168
'[not(ancestor::*[@data-content-type="html"])] '
170
169
);
171
170
171
+ $ uniqueNodeNameToDecodedOuterHtmlMap = [];
172
+
172
173
foreach ($ htmlContentTypeNodes as $ htmlContentTypeNode ) {
173
174
// Set decoded attribute on all encoded html content types so we don't double decode;
174
175
$ htmlContentTypeNode ->setAttribute ('data-decoded ' , 'true ' );
@@ -191,6 +192,8 @@ private function convertEncodedHtmlContentTypesToPlaceholders(
191
192
192
193
$ uniqueNodeNameToDecodedOuterHtmlMap [$ uniqueNodeName ] = $ decodedOuterHtml ;
193
194
}
195
+
196
+ return $ uniqueNodeNameToDecodedOuterHtmlMap ;
194
197
}
195
198
196
199
/**
0 commit comments