Merge "Validate imeId before rendering"
This commit is contained in:
@@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user