Bartosz Dziewoński has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/393947 )
Change subject: Avoid parsing HTML when building DOM objects, and other jQuery conventions ...................................................................... Avoid parsing HTML when building DOM objects, and other jQuery conventions Mostly this extension was already doing this in the best and simplest way possible. This only fixes a few exceptions I noticed. https://www.mediawiki.org/wiki/Manual:Coding_conventions/JavaScript#Creating_elements Change-Id: Iadcd3500971dfb99962cb5e9d3b31db364bfbdfe --- M modules/ext.advancedSearch.init.js M modules/ui/ext.advancedSearch.ExpandablePane.js M modules/ui/ext.advancedSearch.ImageDimensionInput.js M modules/ui/ext.advancedSearch.NamespaceFilters.js 4 files changed, 19 insertions(+), 9 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/AdvancedSearch refs/changes/47/393947/1 diff --git a/modules/ext.advancedSearch.init.js b/modules/ext.advancedSearch.init.js index 83e1a43..dd66d37 100644 --- a/modules/ext.advancedSearch.init.js +++ b/modules/ext.advancedSearch.init.js @@ -396,7 +396,7 @@ ] ); } ); - var $allOptions = $( '<div>' ).prop( { 'class': 'mw-advancedSearch-fieldContainer' } ); + var $allOptions = $( '<div>' ).addClass( 'mw-advancedSearch-fieldContainer' ); for ( var group in optionSets ) { $allOptions.append( optionSets[ group ].$element ); @@ -452,12 +452,12 @@ } } } ), - namespaceSelectionPreview = $( '<div class="mw-advancedSearch-namespace-selection"></div>' ); + namespaceSelectionPreview = $( '<div>' ).addClass( 'mw-advancedSearch-namespace-selection' ); $advancedSearch.append( namespaceSelectionPreview ); namespaceSelectionPreview .after( namespaceSelection.$element ) - .append( $( '<strong></strong>' ).text( mw.msg( 'advancedSearch-namespaces-search-in' ) ) ) + .append( $( '<strong>' ).text( mw.msg( 'advancedSearch-namespaces-search-in' ) ) ) .append( namespacePresets.$element ); // remove old namespace selection item to avoid double ns parameters diff --git a/modules/ui/ext.advancedSearch.ExpandablePane.js b/modules/ui/ext.advancedSearch.ExpandablePane.js index 582b7fd..c895320 100644 --- a/modules/ui/ext.advancedSearch.ExpandablePane.js +++ b/modules/ui/ext.advancedSearch.ExpandablePane.js @@ -32,7 +32,7 @@ OO.ui.mixin.IndicatorElement.call( this, { indicator: getIndicatorNameForState( myConfig.data ) } ); var self = this; - this.$btn = $( '<div></div>' ) + this.$btn = $( '<div>' ) .addClass( 'oo-ui-buttonElement-button' ) .addClass( 'mw-advancedSearch-expandablePane-button' ) .on( 'click keypress', function ( e ) { @@ -53,7 +53,7 @@ } } ); - this.$dependentPane = $( '<div></div>' ) + this.$dependentPane = $( '<div>' ) .addClass( 'mw-advancedSearch-expandablePane-pane' ); if ( config.hasOwnProperty( 'tabIndex' ) ) { diff --git a/modules/ui/ext.advancedSearch.ImageDimensionInput.js b/modules/ui/ext.advancedSearch.ImageDimensionInput.js index 20e04a3..38db8f4 100644 --- a/modules/ui/ext.advancedSearch.ImageDimensionInput.js +++ b/modules/ui/ext.advancedSearch.ImageDimensionInput.js @@ -40,8 +40,12 @@ this.operatorInput.connect( this, { change: 'onInputChange' } ); this.valueInput.connect( this, { change: 'onInputChange' } ); - this.$element.append( this.operatorInput.$element.wrap( '<div class="operator-container"></div>' ).parent() ); - this.$element.append( this.valueInput.$element.wrap( '<div class="value-container"></div>' ).parent() ); + this.$element.append( + $( '<div>' ).addClass( 'operator-container' ).append( this.operatorInput.$element ) + ); + this.$element.append( + $( '<div>' ).addClass( 'value-container' ).append( this.valueInput.$element ) + ); this.operatorInput.setValue( '>' ); // Workaround for broken default value, see https://phabricator.wikimedia.org/T166783 this.setValuesFromStore(); diff --git a/modules/ui/ext.advancedSearch.NamespaceFilters.js b/modules/ui/ext.advancedSearch.NamespaceFilters.js index b747fd9..1842632 100644 --- a/modules/ui/ext.advancedSearch.NamespaceFilters.js +++ b/modules/ui/ext.advancedSearch.NamespaceFilters.js @@ -38,7 +38,7 @@ mw.libs.advancedSearch.ui.NamespaceFilters.parent.call( this, myConfig ); - this.$namespaceContainer = $( '<span class="mw-advancedSearch-namespaceContainer"></span>' ); + this.$namespaceContainer = $( '<span>' ).addClass( 'mw-advancedSearch-namespaceContainer' ); this.$element.append( this.$namespaceContainer ); this.store = store; @@ -123,7 +123,13 @@ namespaces = this.store.getNamespaces(); this.$namespaceContainer.empty(); $.each( namespaces, function ( idx, key ) { - self.$namespaceContainer.append( $( '<input type="hidden" value=1>' ).prop( 'name', 'ns' + key ) ); + self.$namespaceContainer.append( + $( '<input>' ).attr( { + type: 'hidden', + value: '1', + name: 'ns' + key + } ) + ); } ); }; -- To view, visit https://gerrit.wikimedia.org/r/393947 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iadcd3500971dfb99962cb5e9d3b31db364bfbdfe Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/AdvancedSearch Gerrit-Branch: master Gerrit-Owner: Bartosz Dziewoński <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
