Hoo man has uploaded a new change for review. https://gerrit.wikimedia.org/r/314267
Change subject: Handle null upstream values in ExpertExtender.LanguageSelector ...................................................................... Handle null upstream values in ExpertExtender.LanguageSelector This needs to be a non-empty string, but the function passed in by jQuery.valueview.experts.MonolingualText doesn't guarantee this. Bug: T147419 Change-Id: I6ff4dbbaba5a91795db44f0a200dd05880012f20 --- M src/ExpertExtender/ExpertExtender.LanguageSelector.js M tests/src/ExpertExtender/ExpertExtender.LanguageSelector.tests.js 2 files changed, 28 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/data-values/value-view refs/changes/67/314267/1 diff --git a/src/ExpertExtender/ExpertExtender.LanguageSelector.js b/src/ExpertExtender/ExpertExtender.LanguageSelector.js index 0f7afa3..01a750d 100644 --- a/src/ExpertExtender/ExpertExtender.LanguageSelector.js +++ b/src/ExpertExtender/ExpertExtender.LanguageSelector.js @@ -122,7 +122,7 @@ */ onInitialShow: function() { var value = this._getUpstreamValue(); - if ( this._labels ) { + if ( this._labels && value ) { this.$selector.data( 'languagesuggester' ).setSelectedValue( value, this._labels[ value ] || value ); } else { this.$selector.val( value ); diff --git a/tests/src/ExpertExtender/ExpertExtender.LanguageSelector.tests.js b/tests/src/ExpertExtender/ExpertExtender.LanguageSelector.tests.js index 2818a56..7fd2bad 100644 --- a/tests/src/ExpertExtender/ExpertExtender.LanguageSelector.tests.js +++ b/tests/src/ExpertExtender/ExpertExtender.LanguageSelector.tests.js @@ -38,6 +38,33 @@ } ); + QUnit.test( 'initial draw works when the upstream value is null', function( assert ) { + assert.expect( 1 ); + var languageSelector = new ExpertExtender.LanguageSelector( + { + getAll: function() { return [ 'en' ]; }, + getName: function( code ) { return code === 'en' ? 'en label' : null; } + }, + messageProvider, + function() { + return null; + } + ); + var $extender = $( '<div />' ); + + languageSelector.init( $extender ); + + if ( languageSelector.onInitialShow ) { + languageSelector.onInitialShow(); + } + + if ( languageSelector.draw ) { + languageSelector.draw(); + } + + assert.ok( true ); + } ); + QUnit.test( 'value does not change if upstream value changes', function( assert ) { assert.expect( 2 ); var upstreamValue = 'en'; -- To view, visit https://gerrit.wikimedia.org/r/314267 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6ff4dbbaba5a91795db44f0a200dd05880012f20 Gerrit-PatchSet: 1 Gerrit-Project: data-values/value-view Gerrit-Branch: master Gerrit-Owner: Hoo man <h...@online.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits