vanillajs-browser-helpers
Version:
Collection of convenience code snippets (helpers) that aims to make it a little easier to work with vanilla JS in the browser
29 lines (28 loc) • 1.07 kB
TypeScript
import type { CSSStyleKey, CSSStyleProperties } from './shared/types';
/**
* Set multiple inline styling properties on a DOM element.
*
* NOTE:
* - `null` as value, removes the given property
* - `!important` in the value will be parsed and set correctly
*
* @param elm - DOM element to set the style on
* @param style - Styling to set on the element
* @return All styling on the element
*/
declare function css(elm: HTMLElement, style?: CSSStyleProperties): CSSStyleDeclaration;
/**
* Get or set an inline style property on a DOM element.
*
* NOTE:
* - `null` removes the given property
* - `!important` added to the value, it will be parsed and set correctly
* - Values that are pure numbers or pixel values will be converted to number before returned
*
* @param elm - DOM element to get/set the style on
* @param style - Style property name
* @param value - The new value
* @return The value of the property
*/
declare function css(elm: HTMLElement, property: CSSStyleKey, value?: string | number): string | number | null;
export default css;