diff --git a/modules/ve-mw/dm/nodes/ve.dm.MWLanguageVariantNode.js b/modules/ve-mw/dm/nodes/ve.dm.MWLanguageVariantNode.js index 04e2a60639..aaa0a41308 100644 --- a/modules/ve-mw/dm/nodes/ve.dm.MWLanguageVariantNode.js +++ b/modules/ve-mw/dm/nodes/ve.dm.MWLanguageVariantNode.js @@ -160,27 +160,23 @@ ve.dm.MWLanguageVariantNode.static.toDomElements = function ( dataElement, doc, * renderings. * * @static - * @param {jQuery} $element Element to process + * @param {HTMLElement} container Container element to process * @param {Object|null} opts Preview options * @param {boolean} [opts.describeAll=false] Treat all rules as if the * "describe" flag was set. This displays every language and its associated * text, not just the one appropriate for the current user. - * @return {jQuery} $element */ -ve.dm.MWLanguageVariantNode.static.processVariants = function ( $element, opts ) { - var self = this, - selector = '[typeof="mw:LanguageVariant"]', - $variantElements = $element.find( selector ).addBack( selector ); +ve.dm.MWLanguageVariantNode.static.processVariants = function ( container, opts ) { + var self = this; - $variantElements.each( function ( _, child ) { - var dataMwvJSON = child.getAttribute( 'data-mw-variant' ); - if ( dataMwvJSON && child.tagName !== 'META' ) { + Array.prototype.forEach.call( container.querySelectorAll( '[typeof="mw:LanguageVariant"]' ), function ( element ) { + var dataMwvJSON = element.getAttribute( 'data-mw-variant' ); + if ( dataMwvJSON && element.tagName !== 'META' ) { self.insertPreviewElements( - child, JSON.parse( dataMwvJSON ), opts + element, JSON.parse( dataMwvJSON ), opts ); } } ); - return $element; }; /** @@ -197,10 +193,10 @@ ve.dm.MWLanguageVariantNode.static.processVariants = function ( $element, opts ) */ ve.dm.MWLanguageVariantNode.static.insertPreviewElements = function ( element, variantInfo, opts ) { // Note that `element` can't be a (or other void tag) - $( element ).html( this.getPreviewHtml( variantInfo, opts ) ); + element.innerHTML = this.getPreviewHtml( variantInfo, opts ); // This recurses into the children added by the `html` clause to ensure // that nested variants are expanded. - this.processVariants( $( element ).children(), opts ); + this.processVariants( element, opts ); return element; }; diff --git a/modules/ve-mw/init/apiresponsecache/ve.init.mw.LinkCache.js b/modules/ve-mw/init/apiresponsecache/ve.init.mw.LinkCache.js index abbd04dc0c..f282f48442 100644 --- a/modules/ve-mw/init/apiresponsecache/ve.init.mw.LinkCache.js +++ b/modules/ve-mw/init/apiresponsecache/ve.init.mw.LinkCache.js @@ -118,7 +118,9 @@ ve.init.mw.LinkCache.prototype.styleElement = function ( title, $element, hasFra ve.init.mw.LinkCache.prototype.styleParsoidElements = function ( $elements ) { if ( ve.dm.MWLanguageVariantNode ) { // Render the user's preferred variant in language converter markup - ve.dm.MWLanguageVariantNode.static.processVariants( $elements ); + $elements.each( function ( i, element ) { + ve.dm.MWLanguageVariantNode.static.processVariants( element ); + } ); } }; diff --git a/modules/ve-mw/ui/contextitems/ve.ui.MWLanguageVariantNodeContextItem.js b/modules/ve-mw/ui/contextitems/ve.ui.MWLanguageVariantNodeContextItem.js index 7a004f8956..5c687aeac5 100644 --- a/modules/ve-mw/ui/contextitems/ve.ui.MWLanguageVariantNodeContextItem.js +++ b/modules/ve-mw/ui/contextitems/ve.ui.MWLanguageVariantNodeContextItem.js @@ -156,7 +156,7 @@ ve.ui.MWLanguageVariantNodeContextItem.prototype.renderBody = function () { name = ve.init.platform.getLanguageName( code.toLowerCase() ), $text = $( '' ).html( item.t ); ve.dm.MWLanguageVariantNode.static.processVariants( - $text, { showHidden: true } + $text[ 0 ], { showHidden: true } ); $table .append( $( '' ) @@ -174,7 +174,7 @@ ve.ui.MWLanguageVariantNodeContextItem.prototype.renderBody = function () { // Don't put $table in $body if the table is empty; this allows // CSS :empty rules to have their proper effect. ve.dm.MWLanguageVariantNode.static.processVariants( - $table, { showHidden: true } + $table[ 0 ], { showHidden: true } ); $body.append( $table ); }