mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
init
This commit is contained in:
parent
ba97d7143d
commit
779eb31e4e
53 changed files with 8475 additions and 0 deletions
|
@ -0,0 +1,27 @@
|
|||
class ErrorHandler {
|
||||
|
||||
constructor() {
|
||||
this.wrapper = document.querySelector('.woocommerce-notices-wrapper');
|
||||
}
|
||||
|
||||
message(text) {
|
||||
this.wrapper.classList.add('woocommerce-error');
|
||||
this.wrapper.innerText = this.sanitize(text);
|
||||
}
|
||||
|
||||
sanitize(text) {
|
||||
const textarea = document.createElement('textarea');
|
||||
textarea.innerHTML = text;
|
||||
return textarea.value;
|
||||
}
|
||||
|
||||
clear() {
|
||||
if (! this.wrapper.classList.contains('woocommerce-error')) {
|
||||
return;
|
||||
}
|
||||
this.wrapper.classList.remove('woocommerce-error');
|
||||
this.wrapper.innerText = '';
|
||||
}
|
||||
}
|
||||
|
||||
export default ErrorHandler;
|
Loading…
Add table
Add a link
Reference in a new issue