From: Kunal Mehta Date: Tue, 15 Aug 2017 20:00:27 +0000 (-0700) Subject: OutputPage: Turn html5shiv into a raw ResourceLoader module X-Git-Tag: 1.31.0-rc.0~1894 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=68237fb1a74ba3c70f0960cfd33e9033874c07e4 OutputPage: Turn html5shiv into a raw ResourceLoader module This lets us take advantage of ResourceLoader's on the fly minification rather than needing to ship a minified copy, which is problematic for other distributions like Debian. Because the startup module excludes raw modules, it is not possible to load or depend upon this module, and trying to use `mw.loader.load('html5shiv')` for example will throw an exception. This follows-up 3a30e03645f895b. Change-Id: I635e224fb043c614c4918771c7c8f836575c683b --- diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 7c463b6f02..5d9006a731 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -2923,15 +2923,14 @@ class OutputPage extends ContextSource { $pieces = array_merge( $pieces, array_values( $this->getHeadLinksArray() ) ); $pieces = array_merge( $pieces, array_values( $this->mHeadItems ) ); - $min = ResourceLoader::inDebugMode() ? '' : '.min'; // Use an IE conditional comment to serve the script only to old IE $pieces[] = ''; $pieces[] = Html::closeElement( 'head' ); diff --git a/resources/Resources.php b/resources/Resources.php index f697e414e6..b31926b79f 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -2656,6 +2656,21 @@ return [ 'targets' => [ 'desktop', 'mobile' ], ], + /** + * html5shiv + * + * This library is intended to run on older browsers + * that MediaWiki no longer supports as Grade A, and + * is not loaded through the normal module loading + * system. + */ + 'html5shiv' => [ + 'scripts' => [ + 'resources/lib/html5shiv/html5shiv.js' + ], + 'raw' => true, + ], + /* OOjs */ 'oojs' => [ 'scripts' => [ diff --git a/resources/lib/html5shiv/html5shiv.min.js b/resources/lib/html5shiv/html5shiv.min.js deleted file mode 100644 index 355afd1060..0000000000 --- a/resources/lib/html5shiv/html5shiv.min.js +++ /dev/null @@ -1,4 +0,0 @@ -/** -* @preserve HTML5 Shiv 3.7.3 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed -*/ -!function(a,b){function c(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x",d.insertBefore(c.lastChild,d.firstChild)}function d(){var a=t.elements;return"string"==typeof a?a.split(" "):a}function e(a,b){var c=t.elements;"string"!=typeof c&&(c=c.join(" ")),"string"!=typeof a&&(a=a.join(" ")),t.elements=c+" "+a,j(b)}function f(a){var b=s[a[q]];return b||(b={},r++,a[q]=r,s[r]=b),b}function g(a,c,d){if(c||(c=b),l)return c.createElement(a);d||(d=f(c));var e;return e=d.cache[a]?d.cache[a].cloneNode():p.test(a)?(d.cache[a]=d.createElem(a)).cloneNode():d.createElem(a),!e.canHaveChildren||o.test(a)||e.tagUrn?e:d.frag.appendChild(e)}function h(a,c){if(a||(a=b),l)return a.createDocumentFragment();c=c||f(a);for(var e=c.frag.cloneNode(),g=0,h=d(),i=h.length;i>g;g++)e.createElement(h[g]);return e}function i(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return t.shivMethods?g(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+d().join().replace(/[\w\-:]+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(t,b.frag)}function j(a){a||(a=b);var d=f(a);return!t.shivCSS||k||d.hasCSS||(d.hasCSS=!!c(a,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),l||i(a,d),a}var k,l,m="3.7.3",n=a.html5||{},o=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,p=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,q="_html5shiv",r=0,s={};!function(){try{var a=b.createElement("a");a.innerHTML="",k="hidden"in a,l=1==a.childNodes.length||function(){b.createElement("a");var a=b.createDocumentFragment();return"undefined"==typeof a.cloneNode||"undefined"==typeof a.createDocumentFragment||"undefined"==typeof a.createElement}()}catch(c){k=!0,l=!0}}();var t={elements:n.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video",version:m,shivCSS:n.shivCSS!==!1,supportsUnknownElements:l,shivMethods:n.shivMethods!==!1,type:"default",shivDocument:j,createElement:g,createDocumentFragment:h,addElements:e};a.html5=t,j(b),"object"==typeof module&&module.exports&&(module.exports=t)}("undefined"!=typeof window?window:this,document); \ No newline at end of file