Skip to main content
Module

x/lunchbox/src/utils.ts>partializeClasses

Component Library 🍱 for Deno πŸ¦• Fresh πŸ‹
Latest
function partializeClasses
import { partializeClasses } from "https://deno.land/x/lunchbox@v0.3.15/src/utils.ts";

When adding class to an element, say: <div class={x} /> and x's value ends up being an empty string (''), the element will render <div class /> and end up with tons of empty class attributes. This function simplifies the code that replaces parts that end up having an empty string and makes them have undefined value.

Parameters

classes: Record<string, string>

record of parts that might contain empty string values.

Returns

Record<string, string | undefined>

A new record of the same parts but an undefined value replaced empty string values.