Validate imeId before rendering
Fix: TypeError: $.ime.sources[imeId] is undefined Bug: 49584 Change-Id: I9f5615d8b6729d76feae04e195a5ec6f26676bda
This commit is contained in:
@@ -161,9 +161,22 @@
|
||||
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 ) {
|
||||
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( {
|
||||
'for': imeId,
|
||||
'class': 'imelabel'
|
||||
@@ -184,7 +197,8 @@
|
||||
} else {
|
||||
inputmethod = $.ime.inputmethods[imeId];
|
||||
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;
|
||||
description = '';
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user