Skip to content

Commit 1e5e1d0

Browse files
committed
AC-9831: Block template render enhancement
1 parent 5fbf54a commit 1e5e1d0

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

lib/internal/Magento/Framework/Filter/Template.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,11 @@ protected function getParameters($value)
514514
$tokenizer->setString($value);
515515
$params = $tokenizer->tokenize();
516516
foreach ($params as $key => $value) {
517+
$validKey = strtolower($key);
518+
if(strcmp($key,$validKey)) {
519+
$params[$validKey] = $value;
520+
unset($params[$key]);
521+
}
517522
if ($value !== null && substr($value, 0, 1) === '$') {
518523
$params[$key] = $this->getVariable(substr($value, 1), null);
519524
}

lib/internal/Magento/Framework/View/Element/AbstractBlock.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ abstract class AbstractBlock extends \Magento\Framework\DataObject implements Bl
4141
*/
4242
public const CACHE_KEY_PREFIX = 'BLOCK_';
4343

44+
/**
45+
* Prefix for custom cache key of block
46+
*/
47+
public const CUSTOM_CACHE_KEY_PREFIX = 'CUSTOM_BLOCK_';
48+
4449
/**
4550
* @var \Magento\Framework\View\DesignInterface
4651
*/
@@ -1042,7 +1047,7 @@ public function getCacheKeyInfo()
10421047
public function getCacheKey()
10431048
{
10441049
if ($this->hasData('cache_key')) {
1045-
return static::CACHE_KEY_PREFIX . $this->getData('cache_key');
1050+
return static::CUSTOM_CACHE_KEY_PREFIX . $this->getData('cache_key');
10461051
}
10471052

10481053
/**

lib/internal/Magento/Framework/View/Element/Html/Link.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ private function renderSpecialAttributes(): string
184184
);
185185
}
186186
}
187-
return $this->_escaper->escapeJsQuote($html);
187+
188+
return $html;
188189
}
189190
}

lib/internal/Magento/Framework/View/Test/Unit/Element/Html/LinkTest.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,11 @@ public function testLinkHtml(): void
161161
$this->link->setDataUsingMethod('style', 'display: block;');
162162
$this->link->setDataUsingMethod('onclick', 'alert("clicked");');
163163

164-
/** @var Escaper $escaper */
165-
$escaper = $this->objectManager->getObject(Escaper::class);
166-
167164
$html = $this->link->toHtml();
168165
$this->assertEquals(
169-
$escaper->escapeJsQuote('<li><a href="http://site.com/link.html" id="idrandom" ></a></li>'
166+
'<li><a href="http://site.com/link.html" id="idrandom" ></a></li>'
170167
.'<style>#idrandom { display: block; }</style>'
171-
.'<script>document.querySelector(\'#idrandom\').onclick = function () { alert("clicked"); };</script>'),
168+
.'<script>document.querySelector(\'#idrandom\').onclick = function () { alert("clicked"); };</script>',
172169
$html
173170
);
174171
}

0 commit comments

Comments
 (0)