Skip to content

Commit 81e0a6d

Browse files
committed
Fix Wrong ratings at second Catalog Product List at cms page widget
1 parent dfe7b89 commit 81e0a6d

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

lib/internal/Magento/Framework/View/Helper/SecureHtmlRenderer.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,17 @@ public function renderStyleAsTag(string $style, string $selector): string
161161
$stylesAssignments .= "$elementVariable.style.$styleAttribute = '$styleValue';\n";
162162
}
163163

164-
return $this->renderTag(
165-
'script',
166-
['type' => 'text/javascript'],
167-
"var $elementVariable = document.querySelector('$selector');\n"
168-
. "if ($elementVariable) {\n{$stylesAssignments}}",
169-
false
170-
);
164+
$script = <<<script
165+
var {$elementVariable}Array = document.querySelectorAll("{$selector}");
166+
if({$elementVariable}Array.length !== 'undefined'){
167+
{$elementVariable}Array.forEach(function(element) {
168+
if (element) {
169+
{$stylesAssignments}
170+
}
171+
});
172+
}
173+
script;
174+
175+
return $this->renderTag('script', ['type' => 'text/javascript'], $script, false);
171176
}
172177
}

0 commit comments

Comments
 (0)