export const inheritAttributes = (el, attributes = []) => {
    const attributeObject = {};
    attributes.forEach((attr) => {
        if (el.hasAttribute(attr)) {
            const value = el.getAttribute(attr);
            if (value !== null) {
                attributeObject[attr] = el.getAttribute(attr);
            }
            el.removeAttribute(attr);
        }
    });
    return attributeObject;
};
export class AttributeObserver {
    constructor(element, callback) {
        this.element = element;
        this.callback = callback;
    }
    startObserving(attributes) {
        this.mutationObserver = new MutationObserver((mutationsList) => {
            for (const mutation of mutationsList) {
                if (mutation.type === 'attributes' && mutation.attributeName) {
                    const newValue = this.element.getAttribute(mutation.attributeName);
                    if (newValue !== null) {
                        this.callback(mutation.attributeName, newValue);
                    }
                }
            }
        });
        this.mutationObserver.observe(this.element, {
            attributes: true,
            attributeFilter: attributes,
        });
    }
    stopObserving() {
        if (this.mutationObserver) {
            this.mutationObserver.disconnect();
        }
    }
}
//# sourceMappingURL=attribute.js.map
