Validate imeId before rendering

Fix: TypeError: $.ime.sources[imeId] is undefined

Bug: 49584
Change-Id: I9f5615d8b6729d76feae04e195a5ec6f26676bda
This commit is contained in:
Santhosh Thottingal
2013-06-17 10:08:16 +05:30
parent 3bc6a71253
commit 34d4045c3b

View File

@@ -161,9 +161,22 @@
this.$parent.position(); this.$parent.position();
}, },
/*
* For the given input method id, render the selection option.
*
* @param {string} imeId Input method id
* @param {boolean} selected Whether the input is the currently selected one.
* @return {Object} jQuery object corresponding to the input method item.
*/
renderInputmethodOption: function ( imeId, selected ) { renderInputmethodOption: function ( imeId, selected ) {
var $imeLabel, name, description, inputmethod, $inputMethodItem; var $imeLabel, name, description, inputmethod, $inputMethodItem;
if ( imeId !== 'system' && !$.ime.sources[imeId] ) {
// imeId not known for jquery.ime.
// It is very rare, but still validate it.
return $();
}
$imeLabel = $( '<label>' ).attr( { $imeLabel = $( '<label>' ).attr( {
'for': imeId, 'for': imeId,
'class': 'imelabel' 'class': 'imelabel'
@@ -184,7 +197,8 @@
} else { } else {
inputmethod = $.ime.inputmethods[imeId]; inputmethod = $.ime.inputmethods[imeId];
if ( !inputmethod ) { if ( !inputmethod ) {
// Delay in registration? // The input method definition(rules) not loaded.
// We will show the name from $.ime.sources
name = $.ime.sources[imeId].name; name = $.ime.sources[imeId].name;
description = ''; description = '';
} else { } else {