MDL-62497 javascript: add babel polyfill for es6 support

This commit is contained in:
Ryan Wyllie 2018-06-08 11:30:12 +08:00 committed by Andrew Nicols
parent 8d9614b341
commit 67b2262938
7 changed files with 6983 additions and 2 deletions

View File

@ -61,6 +61,7 @@ lib/validateurlsyntax.php
lib/amd/src/popper.js
lib/geopattern-php/
lib/php-jwt/
lib/babel-polyfill/
media/player/videojs/amd/src/video-lazy.js
media/player/videojs/amd/src/Youtube-lazy.js
media/player/videojs/videojs/
@ -81,4 +82,4 @@ theme/boost/amd/src/tab.js
theme/boost/amd/src/tooltip.js
theme/boost/amd/src/util.js
theme/boost/amd/src/tether.js
theme/boost/scss/fontawesome/
theme/boost/scss/fontawesome/

View File

@ -62,6 +62,7 @@ lib/validateurlsyntax.php
lib/amd/src/popper.js
lib/geopattern-php/
lib/php-jwt/
lib/babel-polyfill/
media/player/videojs/amd/src/video-lazy.js
media/player/videojs/amd/src/Youtube-lazy.js
media/player/videojs/videojs/
@ -82,4 +83,4 @@ theme/boost/amd/src/tab.js
theme/boost/amd/src/tooltip.js
theme/boost/amd/src/util.js
theme/boost/amd/src/tether.js
theme/boost/scss/fontawesome/
theme/boost/scss/fontawesome/

File diff suppressed because it is too large Load Diff

4
lib/babel-polyfill/polyfill.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,6 @@
Installation instructions can be found at https://babeljs.io/docs/en/babel-polyfill.html#usage-in-browser
The steps are essentially:
1.) npm install @babel/polyfill
2.) copy polyfill.js and polyfill.min.js from the "dist" folder from the npm release into lib/babel-polyfill/
3.) npm uninstall --save @babel/polyfill (don't want to include that with Moodle package.json)

View File

@ -1569,9 +1569,19 @@ class page_requirements_manager {
* @return string the HTML code to go at the start of the <body> tag.
*/
public function get_top_of_body_code(renderer_base $renderer) {
global $CFG;
// First the skip links.
$output = $renderer->render_skip_links($this->skiplinks);
// The polyfill needs to load before the other JavaScript in order to make sure
// that we have access to the functions it provides.
if (empty($CFG->cachejs)) {
$output .= html_writer::script('', $this->js_fix_url('/lib/babel-polyfill/polyfill.js'));
} else {
$output .= html_writer::script('', $this->js_fix_url('/lib/babel-polyfill/polyfill.min.js'));
}
// YUI3 JS needs to be loaded early in the body. It should be cached well by the browser.
$output .= $this->get_yui3lib_headcode();

View File

@ -302,4 +302,10 @@
<version>5.0.0</version>
<licenseversion>3-Clause</licenseversion>
</library>
<library>
<location>babel-polyfill</location>
<name>babel-polyfill</name>
<license>MIT</license>
<version>6.26.0</version>
</library>
</libraries>