import { IDocument , ITextNode , NodeType } from 'svg-vdom' ; import { regularTag } from '../const/regular-tag' ; import { mixWhiteSpace } from '../utils/mix-white-space' ; export const clearTextNode = async ( dom ) : Promise < void > => new Promise ( resolve => { const textNodes = dom . querySelectorAll ( node => node . nodeType === NodeType . Text || node . nodeType === NodeType . CDATA ) as ITextNode [ ] ; textNodes . forEach ( node => { const parentName = node . parentNode && node . parentNode . nodeName ; if ( parentName && ! regularTag [ parentName ] . containTextNode ) { node . remove ( ) ; } else { node . textContent = mixWhiteSpace ( node . textContent ) ; } } ) ; resolve ( ) ; } ) ;