This commit is contained in:
David Remer 2020-04-02 08:38:00 +03:00
parent ba97d7143d
commit 779eb31e4e
53 changed files with 8475 additions and 0 deletions

View file

@ -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;