All files / src/internal/client/dev css.js

41.93% Statements 13/31
100% Branches 0/0
0% Functions 0/2
41.93% Lines 13/31

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 24 25 26 27 28 29 30 31 322x 2x 2x 2x 2x 2x 2x 2x                   2x 2x 2x 2x 2x                    
/** @type {Map<String, Set<HTMLStyleElement>>} */
var all_styles = new Map();
 
/**
 * @param {String} hash
 * @param {HTMLStyleElement} style
 */
export function register_style(hash, style) {
	var styles = all_styles.get(hash);

	if (!styles) {
		styles = new Set();
		all_styles.set(hash, styles);
	}

	styles.add(style);
}
 
/**
 * @param {String} hash
 */
export function cleanup_styles(hash) {
	var styles = all_styles.get(hash);
	if (!styles) return;

	for (const style of styles) {
		style.remove();
	}

	all_styles.delete(hash);
}