Add UNFORGIVING mode
* This will explicitly throw errors instead of handling them through Event Listeners
This commit is contained in:
@@ -4,11 +4,18 @@ class TemplateE6d extends HTMLTemplateElement {
|
|||||||
this.preprocessed = false;
|
this.preprocessed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
connectedCallback() {
|
||||||
|
this.unforgiving = this.hasAttribute(`data-e6d-unforgiving`);
|
||||||
|
}
|
||||||
|
|
||||||
dispatchError(type, detail) {
|
dispatchError(type, detail) {
|
||||||
const evtBroad = new CustomEvent(`e6d-error`, {detail,});
|
const evtBroad = new CustomEvent(`e6d-error`, {detail,});
|
||||||
const evtSpecific = new CustomEvent(`e6d-error-${ type }`, {detail,});
|
const evtSpecific = new CustomEvent(`e6d-error-${ type }`, {detail,});
|
||||||
this.dispatchEvent(evtBroad);
|
this.dispatchEvent(evtBroad);
|
||||||
this.dispatchEvent(evtSpecific);
|
this.dispatchEvent(evtSpecific);
|
||||||
|
if (this.unforgiving) {
|
||||||
|
throw new Error(`${ type }: ${ JSON.stringify(detail) }`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
preprocess() {
|
preprocess() {
|
||||||
@@ -122,9 +129,6 @@ class TemplateE6d extends HTMLTemplateElement {
|
|||||||
this.preprocessed = true;
|
this.preprocessed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
connectedCallback() {
|
|
||||||
}
|
|
||||||
|
|
||||||
bind(obj = {}) {
|
bind(obj = {}) {
|
||||||
this.preprocess();
|
this.preprocess();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user