import {OOElement} from '../oo-element' import {html} from '../../lib/html' import weakMap from '../../lib/weak-map' import {NotificationType} from '../../type/event' type Type = NotificationType | '' const ATTR = { DATA_TYPE: 'data-type' } const stateType = weakMap() const asType = (data: string): Type => { if (data === 'error' || data === 'success' || data === '') { return data } return '' } export default class extends OOElement { static get observedAttributes() { return [ATTR.DATA_TYPE] } constructor() { super() stateType.set(this, asType(this.getAttribute(ATTR.DATA_TYPE))) } attributeChangedCallback(attr, prev, next) { if (prev === next) { return } stateType.set(this, asType(next)) if (this.connected) { this.update() } } render() { const type = stateType.get(this) return html`
` } }