Skip to content

Commit 8a828f9

Browse files
committed
MC-4189: IE11 - PageBuilder Does Not Load
- Load IE 11 using server side user agent checks - Re-compile tinymce4.js
1 parent 8ed97ee commit 8a828f9

File tree

3 files changed

+35
-12
lines changed

3 files changed

+35
-12
lines changed

app/code/Magento/PageBuilder/Block/Adminhtml/Html/Head/BabelPolyfill.php

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,43 @@
1717
*/
1818
class BabelPolyfill extends Template
1919
{
20+
const IE_11_USER_AGENT = 'Trident/7.0; rv:11.0';
21+
2022
/**
2123
* @var \Magento\PageBuilder\Model\ConfigInterface
2224
*/
2325
private $config;
2426

27+
/**
28+
* @var \Magento\Framework\HTTP\Header
29+
*/
30+
private $httpHeader;
31+
2532
/**
2633
* @param Template\Context $context
2734
* @param \Magento\PageBuilder\Model\ConfigInterface $config
35+
* @param \Magento\Framework\HTTP\Header $httpHeader
2836
* @param array $data
2937
*/
3038
public function __construct(
3139
Template\Context $context,
3240
\Magento\PageBuilder\Model\ConfigInterface $config,
41+
\Magento\Framework\HTTP\Header $httpHeader,
3342
array $data = []
3443
) {
3544
$this->config = $config;
45+
$this->httpHeader = $httpHeader;
3646
parent::__construct($context, $data);
3747
}
3848

3949
/**
40-
* Detect if Page Builder is enabled before loading the polyfill
50+
* Detect if Page Builder is enabled and the user is loading the website from IE 11
4151
*
4252
* @return bool
4353
*/
4454
public function shouldLoadPolyfill() : bool
4555
{
46-
return $this->config->isEnabled();
56+
return $this->config->isEnabled() && $this->isIe11();
4757
}
4858

4959
/**
@@ -55,4 +65,26 @@ public function getJsUrl() : string
5565
{
5666
return $this->_assetRepo->getUrl("Magento_PageBuilder::js/resource/babel/polyfill.min.js");
5767
}
68+
69+
/**
70+
* Extend the cache keys with a IE 11 flag
71+
*
72+
* @return array
73+
*/
74+
public function getCacheKeyInfo() : array
75+
{
76+
$cacheKeys = parent::getCacheKeyInfo();
77+
$cacheKeys['is_ie11'] = $this->isIe11();
78+
return $cacheKeys;
79+
}
80+
81+
/**
82+
* Detect if the browser user agent contains the IE 11 user agent
83+
*
84+
* @return bool
85+
*/
86+
private function isIe11() : bool
87+
{
88+
return strpos($this->httpHeader->getHttpUserAgent(), self::IE_11_USER_AGENT) !== false;
89+
}
5890
}

app/code/Magento/PageBuilder/view/adminhtml/templates/html/head/babel_polyfill.phtml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77
/* @var $block \Magento\PageBuilder\Block\Adminhtml\Html\Head\BabelPolyfill */
88

99
if ($block->shouldLoadPolyfill()) : ?>
10-
<script>
11-
if (/MSIE \d|Trident.*rv:/.test(navigator.userAgent)) {
12-
document.write('<script src="<?= $block->escapeUrl($block->getJsUrl()) ?>"><\/script>');
13-
}
14-
</script>
10+
<script src="<?= $block->escapeUrl($block->getJsUrl()) ?>"></script>
1511
<?php endif; ?>
1612

app/code/Magento/PageBuilder/view/adminhtml/web/js/wysiwyg/tinymce4.js

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)