Skip to content

Commit

Permalink
fix(core): fix bug when checking if plugin exists (#1348)
Browse files Browse the repository at this point in the history
* fix(cordova-plugin): add check if method exists

For #1327

* fix(plugin): add typeof to undefined check
  • Loading branch information
AmitMY authored and ihadeed committed Apr 14, 2017
1 parent f396940 commit 4bd6aab
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/@ionic-native/core/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function checkAvailability(plugin: any, methodName?: string, pluginName?:

pluginInstance = getPlugin(pluginRef);

if (!pluginInstance || (!!methodName && pluginInstance[methodName] === 'undefined')) {
if (!pluginInstance || (!!methodName && typeof pluginInstance[methodName] === 'undefined')) {
if (!window.cordova) {
cordovaWarn(pluginName, methodName);
return {
Expand All @@ -54,7 +54,7 @@ export function checkAvailability(plugin: any, methodName?: string, pluginName?:
* @private
*/
export function instanceAvailability(pluginObj: any, methodName?: string): boolean {
return pluginObj._objectInstance && (!methodName || pluginObj._objectInstance[methodName] !== 'undefined');
return pluginObj._objectInstance && (!methodName || typeof pluginObj._objectInstance[methodName] !== 'undefined');
}

function setIndex(args: any[], opts: any = {}, resolve?: Function, reject?: Function): any {
Expand Down

0 comments on commit 4bd6aab

Please sign in to comment.