import { Renderer2 } from '@angular/core' ; function removeClass ( el , classMap , renderer ) { Object . keys ( classMap ) . forEach ( key => renderer . removeClass ( el , key ) ) ; } function addClass ( el , classMap , renderer ) { for ( const i in classMap ) { if ( classMap [ i ] ) { renderer . addClass ( el , i ) ; } } } /**
 * Update host component style `class`
 *
 * 更新宿主组件样式 `class`
 *
 * ```ts
 * updateHostClass(
 *  this.el.nativeElement,
 *  this.renderer,
 *  {
 *    [ 'classname' ]: true,
 *    [ 'classname' ]: this.type === '1',
 *    [ this.cls ]: true,
 *    [ `a-${this.cls}` ]: true
 *  })
 * ```
 */ export function updateHostClass ( el , renderer , classMap , preClean = false ) { if ( preClean === true ) { renderer . removeAttribute ( el , 'class' ) ; } else { removeClass ( el , classMap , renderer ) ; } classMap = { ... classMap } ; addClass ( el , classMap , renderer ) ; }