All files / src/internal/client/dom/elements style.js

100% Statements 23/23
83.33% Branches 5/6
100% Functions 1/1
100% Lines 23/23

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 242x 2x 2x 2x 2x 2x 2x 142x 142x 142x 142x 36x 36x 106x 106x 106x 106x 142x 10x 142x 96x 96x 142x  
/**
 * @param {HTMLElement} dom
 * @param {string} key
 * @param {string} value
 * @param {boolean} [important]
 */
export function set_style(dom, key, value, important) {
	// @ts-expect-error
	var attributes = (dom.__attributes ??= {});
 
	if (attributes['style-' + key] === value) {
		return;
	}
 
	attributes['style-' + key] = value;
	var style = dom.style;
 
	if (value == null) {
		style.removeProperty(key);
	} else {
		style.setProperty(key, value, important ? 'important' : '');
	}
}