From: Stephane Bisson Date: Thu, 16 Apr 2015 14:06:30 +0000 (-0400) Subject: Polyfill node types in browsers without DOM level 2 X-Git-Tag: 1.31.0-rc.0~11647^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22upgrade%22%2C%22reinstall=non%22%29%20.%20%22?a=commitdiff_plain;h=5edae663bc72d7070bd36863bcc014d2cc807f92;p=lhc%2Fweb%2Fwiklou.git Polyfill node types in browsers without DOM level 2 mediawiki.jqueryMsg.js:1144 was blowing up on Node.TEXT_NODE because window.Node is undefined in IE8. The exception was ignored and this was causing a message containing {{PLURAL...}} or {{GENDER...}} to be rendered as is. Bug: T87118 Change-Id: I8c5c2ae74b68eeabd93bb5b81a3061bcb31f6549 --- diff --git a/resources/Resources.php b/resources/Resources.php index ec5a9a04bc..e2f05b6194 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -1269,6 +1269,7 @@ return array( 'dependencies' => array( 'mediawiki.util', 'mediawiki.language', + 'dom-level2-shim', ), 'targets' => array( 'desktop', 'mobile' ), ), @@ -1695,6 +1696,14 @@ return array( 'skipFunction' => 'resources/src/es5-skip.js', ), + /* dom-level2-shim */ + // IE 8 + 'dom-level2-shim' => array( + 'scripts' => 'resources/src/polyfill-nodeTypes.js', + 'targets' => array( 'desktop', 'mobile' ), + 'skipFunction' => 'resources/src/dom-level2-skip.js', + ), + /* OOjs */ 'oojs' => array( 'scripts' => array( diff --git a/resources/src/dom-level2-skip.js b/resources/src/dom-level2-skip.js new file mode 100644 index 0000000000..484c295ebe --- /dev/null +++ b/resources/src/dom-level2-skip.js @@ -0,0 +1,6 @@ +/*! + * Skip function for dom-level2-shim module. + * + * Tests for window.Node because that's the only thing that this shim is adding. + */ +return !!window.Node; diff --git a/resources/src/polyfill-nodeTypes.js b/resources/src/polyfill-nodeTypes.js new file mode 100644 index 0000000000..556b51b4fd --- /dev/null +++ b/resources/src/polyfill-nodeTypes.js @@ -0,0 +1,19 @@ +/** + * Adds window.Node with node types according to: + * http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-1950641247 + */ + +window.Node = window.Node || { + ELEMENT_NODE: 1, + ATTRIBUTE_NODE: 2, + TEXT_NODE: 3, + CDATA_SECTION_NODE: 4, + ENTITY_REFERENCE_NODE: 5, + ENTITY_NODE: 6, + PROCESSING_INSTRUCTION_NODE: 7, + COMMENT_NODE: 8, + DOCUMENT_NODE: 9, + DOCUMENT_TYPE_NODE: 10, + DOCUMENT_FRAGMENT_NODE: 11, + NOTATION_NODE: 12 +};