woocommerce-paypal-payments/modules/ppcp-wc-gateway/resources/js/common/display-manager/condition/JsVariableCondition.js

25 lines
558 B
JavaScript
Raw Normal View History

import BaseCondition from "./BaseCondition";
class JsVariableCondition extends BaseCondition {
register() {
jQuery(document).on('ppcp-display-change', () => {
const status = this.check();
if (status !== this.status) {
this.status = status;
this.triggerUpdate();
}
});
this.status = this.check();
}
check() {
let value = document[this.config.variable];
return this.config.value === value;
}
}
export default JsVariableCondition;