param doc internal export default function domElementCache ( doc ) { const cache = new Map < string , HTMLElement > ( ) ; const helper = doc . createElement ( 'div' ) ; return ( html ) => { if ( cache . has ( html ) ) { return cache . get ( html ) ! . cloneNode ( true ) as HTMLElement ; } helper . innerHTML = html ; const node = helper . firstElementChild ! as HTMLElement ; cache . set ( html , node . cloneNode ( true ) as HTMLElement ) ; return node ; } ; } export function createSanitizer ( doc ) { const textNode = doc . createTextNode ( '' ) ; const wrapper = doc . createElement ( 'div' ) ; wrapper . appendChild ( textNode ) ; return ( v ) => { if ( ! v ) { return '' ; } textNode . nodeValue = v ; return wrapper . innerHTML ; } ; }