namespace pxt . dom { export function el ( name , attributes ? , children ? ) { const el = document . createElement ( name ) ; if ( attributes ) Object . keys ( attributes ) . forEach ( k => el . setAttribute ( k , attributes [ k ] + "" ) ) ; appendChild ( children ) ; return el ; function appendChild ( c ) { if ( Array . isArray ( c ) ) c . forEach ( cc => appendChild ( cc ) ) ; else if ( typeof c === "string" ) el . appendChild ( document . createTextNode ( c as string ) ) ; else if ( c instanceof HTMLElement ) el . appendChild ( c as HTMLElement ) ; } } }