UNPKG

vite-awesome-svg-loader

Version:

A universal Vite SVG loader. Imports SVGs as source code, base64 and data URI. Preserves stroke width. Replaces colors with currentColor or custom colors. Creates SVG sprites. Optimizes SVGs.

50 lines (49 loc) 1.61 kB
/** * HTML element or selector that will be passed to `document.querySelector()` */ export type ElementOrSelector = Element | string; /** * */ export type SettableAttributeValue = string | null | undefined; /** * Appends given element to the given container * @param el Element to append * @param to Container * @returns Container */ export declare function mount(el: Element, to: ElementOrSelector): Element | undefined; /** * Sets attributes of an element. Ignores `id`, `class` and `style` attributes. * * @param el Element to set attributes of * @param attrs Attributes object * @param clear If `true`, all element attributes will be cleared */ export declare function setAttrs(el: Element, attrs: Record<string, SettableAttributeValue>): void; /** * Clears attributes of an element. * * @param el Element whose attributes must be cleared */ export declare function clearAttrs(el: Element): void; /** * Sets an attribute of an element * * @param el Element * @param name Attribute name * @param value Attribute value */ export declare function setAttr(el: Element, name: string, value: SettableAttributeValue): void; /** * Creates and appends to the `<head>` a unique style element. Behavior: * * 1. If there's no element with the given ID, will create a style element. * 1. If existing element **is** a style, won't do anything. * 1. If existing element **is not** a style, it will be replaced with a style element * * @param id Style ID * @param css CSS styles * @returns Created style element */ export declare function createStyle(id: string, css: string): HTMLElement;