mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-05-07 10:55:22 +08:00
fix(cordova-property): fixes static properties of classes
This commit is contained in:
parent
ea53a1923a
commit
7ae6e10375
@ -407,31 +407,27 @@ export function CordovaInstance(opts: any = {}) {
|
|||||||
*
|
*
|
||||||
* Before calling the original method, ensure Cordova and the plugin are installed.
|
* Before calling the original method, ensure Cordova and the plugin are installed.
|
||||||
*/
|
*/
|
||||||
export function CordovaProperty(target: Function, key: string) {
|
export function CordovaProperty(target: any, key: string) {
|
||||||
let exists: Function = function(): boolean {
|
const exists = () => {
|
||||||
if (!window.cordova) {
|
let pluginInstance = getPlugin(target.pluginRef);
|
||||||
cordovaWarn(this.name, null);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
let pluginInstance = getPlugin(this.pluginRef);
|
|
||||||
if (!pluginInstance) {
|
if (!pluginInstance) {
|
||||||
pluginWarn(this, key);
|
pluginWarn(target, key);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.defineProperty(target, key, {
|
Object.defineProperty(target, key, {
|
||||||
get: function() {
|
get: () => {
|
||||||
if (exists) {
|
if (exists()) {
|
||||||
return this.pluginRef[key];
|
return getPlugin(target.pluginRef)[key];
|
||||||
} else {
|
} else {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
set: function(value) {
|
set: (value) => {
|
||||||
if (exists) {
|
if (exists()) {
|
||||||
this.pluginRef[key] = value;
|
getPlugin(target.pluginRef)[key] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user