Skip to content

Commit

Permalink
fix(core): Call native implementation before web implementation (#4493)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile committed Apr 27, 2021
1 parent d0ec80b commit febd606
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions core/src/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,8 @@ export const createCapacitor = (win: WindowCapacitor): CapacitorInstance => {
impl: any,
prop: PropertyKey,
): ((...args: any[]) => any) => {
if (impl) {
return impl[prop]?.bind(impl);
} else if (pluginHeader) {
const methodHeader = pluginHeader.methods.find(m => prop === m.name);

if (pluginHeader) {
const methodHeader = pluginHeader?.methods.find(m => prop === m.name);
if (methodHeader) {
if (methodHeader.rtype === 'promise') {
return (options: any) =>
Expand All @@ -134,7 +131,11 @@ export const createCapacitor = (win: WindowCapacitor): CapacitorInstance => {
callback,
);
}
} else if (impl) {
return impl[prop]?.bind(impl);
}
} else if (impl) {
return impl[prop]?.bind(impl);
} else {
throw new CapacitorException(
`"${pluginName}" plugin is not implemented on ${platform}`,
Expand Down

0 comments on commit febd606

Please sign in to comment.