Problem/Motivation
JavaScript theme functions are defined on each library and Drupal.theme() checks property existence. But, a type of property value is not checked so that if a JavaScript theme function is defined other than function, tries to execute as function and occurs an error.
Drupal.theme.test = true;
Drupal.theme.test2 = function() {
// Try to execute Drupal.theme.test() as a function but an error is occurred.
return Drupal.theme('test', false);
}
Proposed resolution
Checks property value type using typeof
operator.