import { deref } from "@thi.ng/api/deref" ; import { isString } from "@thi.ng/checks/is-string" ; remarks example param existing param val export const mergeClasses = ( existing , val ) => { val = deref ( val ) ; if ( val == null ) return existing ; if ( isString ( val ) ) return existing + " " + val ; const classes = new Set ( existing . split ( " " ) ) ; for ( let id in val ) { deref ( val [ id ] ) ? classes . add ( id ) : classes . delete ( id ) ; } return [ ... classes ] . join ( " " ) ; } ; param attribs param id param classes export const mergeEmmetAttribs = ( attribs , id ? , classes ? ) => { id && ( attribs . id = id ) ; let aclass = deref ( attribs . class ) ; if ( classes ) { classes = classes . replace ( /\./g , " " ) ; attribs . class = aclass ? mergeClasses ( classes , aclass ) : classes ; } else if ( aclass ) { attribs . class = isString ( aclass ) ? aclass : mergeClasses ( "" , aclass ) ; } return attribs ; } ;