diff --git a/.eslintignore b/.eslintignore index b4ad30abeb671..19f5a98b5fcef 100644 --- a/.eslintignore +++ b/.eslintignore @@ -61,6 +61,7 @@ lib/amd/src/popper.js lib/geopattern-php/ lib/php-jwt/ lib/babel-polyfill/ +lib/mdn-polyfills/ lib/emoji-data/ lib/h5p/ media/player/videojs/amd/src/video-lazy.js diff --git a/.stylelintignore b/.stylelintignore index 989166f88c570..4d4c82ff8d206 100644 --- a/.stylelintignore +++ b/.stylelintignore @@ -62,6 +62,7 @@ lib/amd/src/popper.js lib/geopattern-php/ lib/php-jwt/ lib/babel-polyfill/ +lib/mdn-polyfills/ lib/emoji-data/ lib/h5p/ media/player/videojs/amd/src/video-lazy.js diff --git a/lib/mdn-polyfills/polyfill.js b/lib/mdn-polyfills/polyfill.js new file mode 100644 index 0000000000000..c74b588f7878f --- /dev/null +++ b/lib/mdn-polyfills/polyfill.js @@ -0,0 +1,18 @@ +!function(){function t(t,e){e=e||{bubbles:!1,cancelable:!1,detail:void 0};var n=document.createEvent("CustomEvent");return n.initCustomEvent(t,e.bubbles,e.cancelable,e.detail),n}"function"!=typeof window.CustomEvent&&(t.prototype=window.Event.prototype,window.CustomEvent=t)}(); +String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}),!window.Element||"classList"in Element.prototype||function(e){function c(e,t){if(""===t)throw new DOMException("Failed to execute '"+e+"' on 'DOMTokenList': The token provided must not be empty.");if(-1!==(wsI=t.search(wsRE)))throw new DOMException("Failed to execute '"+e+"' on 'DOMTokenList': The token provided ('"+t[wsI]+"') contains HTML space characters, which are not valid in tokens.")}var t,n;"function"!=typeof DOMTokenList&&function(f){var t=f.document,e=f.Object,n=e.prototype.hasOwnProperty,v=e.defineProperty,i=0,g=0,d=(f.Element,/[\11\12\14\15\40]/);function s(){if(!i)throw TypeError("Illegal constructor")}function a(){var e=f.event,t=e.propertyName;if(!g&&("className"===t||"classList"===t&&!v)){var n=e.srcElement,r=n[" uCLp"],o=""+n[t],i=o.trim().split(d),s=n["classList"===t?" uCL":"classList"],a=r.length;e:for(var l=0,c=r.length=i.length,u=0;l!==c;++l){for(var h=0;h!==l;++h)if(i[h]===i[l]){u++;continue e}s[l-u]=i[l]}for(var p=c-u;p ../../lib/mdn-polyfills/polyfill.js + +3) Uninstall the package again + + npm uninstall --no-save mdn-polyfills diff --git a/lib/outputrequirementslib.php b/lib/outputrequirementslib.php index 0b7d01addb46f..9dce334347725 100644 --- a/lib/outputrequirementslib.php +++ b/lib/outputrequirementslib.php @@ -1608,6 +1608,9 @@ public function get_top_of_body_code(renderer_base $renderer) { $output .= html_writer::script('', $this->js_fix_url('/lib/babel-polyfill/polyfill.min.js')); } + // Include the MDN Polyfill. + $output .= html_writer::script('', $this->js_fix_url('/lib/mdn-polyfills/polyfill.js')); + // YUI3 JS needs to be loaded early in the body. It should be cached well by the browser. $output .= $this->get_yui3lib_headcode(); diff --git a/lib/thirdpartylibs.xml b/lib/thirdpartylibs.xml index 89c1b67f1f47a..b76432fc6d1a4 100644 --- a/lib/thirdpartylibs.xml +++ b/lib/thirdpartylibs.xml @@ -308,6 +308,12 @@ MIT 6.26.0 + + mdn-polyfills + mdn-polyfill + MIT + 5.19.0 + emoji-data Emoji data