MonitorAttributeErrors
Watches the DOM for `data-monster-error` attributes and can forward them to `monster-notify`.
import { MonitorAttributeErrors } from "@schukai/monster/source/components/notify/monitor-attribute-errors.mjs";Introduction
monster-monitor-attribute-errors watches the DOM for data-monster-error attributes and can surface those issues to users or developers.
Key Features
- Mutation-based monitoring: Observes dynamic DOM changes.
- Console diagnostics: Logs grouped error details for debugging.
- Optional user notification: Can forward detected errors to
monster-notify.
Monitor Attribute Errors Simple
This example monitors the document for data-monster-error attributes and forwards them to monster-notify.
Javascript
import "@schukai/monster/source/components/notify/notify.mjs";
import "@schukai/monster/source/components/notify/monitor-attribute-errors.mjs";
import "@schukai/monster/source/components/form/button.mjs";
const target = document.getElementById("monitor-error-target");
const trigger = document.getElementById("monitor-error-trigger");
const clear = document.getElementById("monitor-error-clear");
trigger.addEventListener("click", () => {
target.textContent = "Watched element with active validation issues";
target.setAttribute(
"data-monster-error",
"Example validation error::Another monitored issue",
);
});
clear.addEventListener("click", () => {
target.textContent = "Watched element";
target.removeAttribute("data-monster-error");
});<script type="module">import "@schukai/monster/source/components/notify/notify.mjs";
import "@schukai/monster/source/components/notify/monitor-attribute-errors.mjs";
import "@schukai/monster/source/components/form/button.mjs";
const target = document.getElementById("monitor-error-target-run");
const trigger = document.getElementById("monitor-error-trigger-run");
const clear = document.getElementById("monitor-error-clear-run");
trigger.addEventListener("click", () => {
target.textContent = "Watched element with active validation issues";
target.setAttribute(
"data-monster-error",
"Example validation error::Another monitored issue",
);
});
clear.addEventListener("click", () => {
target.textContent = "Watched element";
target.removeAttribute("data-monster-error");
});</script>HTML
<monster-notify id="monitor-error-notify"></monster-notify>
<monster-monitor-attribute-errors
id="monitor-error-demo"
data-monster-option-features-notify-user="true"
data-monster-option-notify-user-selector="#monitor-error-notify"
></monster-monitor-attribute-errors>
<div
id="monitor-error-target"
style="padding:0.75rem;border:1px solid var(--monster-color-primary-2);border-radius:var(--monster-border-radius);"
>
Watched element
</div>
<div style="display:flex;flex-wrap:wrap;gap:var(--monster-space-3);margin-top:var(--monster-space-4);">
<monster-button id="monitor-error-trigger">Trigger attribute error</monster-button>
<monster-button id="monitor-error-clear">Clear attribute error</monster-button>
</div>Stylesheet
/** no additional stylesheet is defined **/Component Design
The component uses mutation observers on the document and open shadow roots to detect newly added error attributes.
Configuration
features.notifyUser: Enables notification forwarding.notifyUser.selector: Points to the notify component that should receive messages.
HTML Structure
<monster-monitor-attribute-errors></monster-monitor-attribute-errors>JavaScript Initialization
const element = document.createElement('monster-monitor-attribute-errors');
document.body.appendChild(element);Exported
MonitorAttributeErrorsDerived from
CustomElementOptions
The Options listed in this section are defined directly within the class. This class is derived from several parent classes, including the CustomElement class. Therefore, it inherits Options from these parent classes. If you cannot find a specific Options in this list, we recommend consulting the documentation of the CustomElement.
- since
- deprecated
Properties and Attributes
The Properties and Attributes listed in this section are defined directly within the class. This class is derived from several parent classes, including the CustomElement class and ultimately from HTMLElement. Therefore, it inherits Properties and Attributes from these parent classes. If you cannot find a specific Properties and Attributes in this list, we recommend consulting the documentation of the CustomElement.
data-monster-options: Sets the configuration options for the collapse component when used as an HTML attribute.data-monster-option-[name]: Sets the value of the configuration option[name]for the collapse component when used as an HTML attribute.
Methods
The methods listed in this section are defined directly within the class. This class is derived from several parent classes, including the CustomElement class and ultimately from HTMLElement. Therefore, it inherits methods from these parent classes. If you cannot find a specific method in this list, we recommend consulting the documentation of the CustomElement.
Static methods
[instanceSymbol]()instanceof operator.getCSSStyleSheet()- {CSSStyleSheet[]}
getTag()- {string}
Lifecycle methods
Lifecycle methods are called by the environment and are usually not intended to be called directly.
[assembleMethodSymbol]()- {Components.Notify.MonitorAttributeErrors
connectedCallback()- {void}
disconnectedCallback()- {void}
Events
This component does not fire any public events. It may fire events that are inherited from its parent classes.