/**
 * Contains simple low-level utility functions to manipulate the real DOM.
 */ import { Projection , ProjectionOptions , VNode } from "./interfaces" ; import { createDom , createProjection , extend , initPropertiesAndChildren } from "./projection" ; const DEFAULT_PROJECTION_OPTIONS = { namespace : undefined , performanceLogger : ( ) => undefined , eventHandlerInterceptor : undefined , styleApplyer : ( domNode , styleName , value ) => { if ( styleName . charAt ( 0 ) === "-" ) { domNode . style . setProperty ( styleName , value ) ; } else { ( domNode . style as any ) [ styleName ] = value ; } } , } ; export let applyDefaultProjectionOptions = ( projectorOptions ? ) : ProjectionOptions => { return extend ( DEFAULT_PROJECTION_OPTIONS , projectorOptions ) ; } ; export let dom = { param vnode param projectionOptions returns create : ( vnode , projectionOptions ? ) : Projection => { projectionOptions = applyDefaultProjectionOptions ( projectionOptions ) ; createDom ( vnode , document . createElement ( "div" ) , undefined , projectionOptions ) ; return createProjection ( vnode , projectionOptions ) ; } , param parentNode param vnode param projectionOptions returns append : ( parentNode , vnode , projectionOptions ? ) : Projection => { projectionOptions = applyDefaultProjectionOptions ( projectionOptions ) ; createDom ( vnode , parentNode , undefined , projectionOptions ) ; return createProjection ( vnode , projectionOptions ) ; } , param beforeNode param vnode param projectionOptions returns insertBefore : ( beforeNode , vnode , projectionOptions ? ) : Projection => { projectionOptions = applyDefaultProjectionOptions ( projectionOptions ) ; createDom ( vnode , beforeNode . parentNode ! , beforeNode , projectionOptions ) ; return createProjection ( vnode , projectionOptions ) ; } , param element param vnode param projectionOptions returns merge : ( element , vnode , projectionOptions ? ) : Projection => { projectionOptions = applyDefaultProjectionOptions ( projectionOptions ) ; vnode . domNode = element ; initPropertiesAndChildren ( element , vnode , projectionOptions ) ; return createProjection ( vnode , projectionOptions ) ; } , param element param vnode param projectionOptions returns replace : ( element , vnode , projectionOptions ? ) : Projection => { projectionOptions = applyDefaultProjectionOptions ( projectionOptions ) ; createDom ( vnode , element . parentNode ! , element , projectionOptions ) ; element . parentNode ! . removeChild ( element ) ; return createProjection ( vnode , projectionOptions ) ; } , } ;