import MagicString from 'magic-string' ; import { getSlotName } from '../../utils/svelteAst' ; import { handleSlot } from './slot' ; import { IfScope } from './if-scope' ; import { TemplateScope } from '../nodes/template-scope' ; import { BaseNode } from '../../interfaces' ; /**
 * Special treatment for self-closing / void tags to make them conform to JSX.
 */ export function handleElement ( htmlx , str , node , parent , ifScope , templateScope ) { const slotName = getSlotName ( node ) ; if ( slotName ) { handleSlot ( htmlx , str , node , parent , slotName , ifScope , templateScope ) ; } const voidTags = 'area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr' . split ( ',' ) ; if ( voidTags . find ( ( x ) => x == node . name ) ) { if ( htmlx [ node . end - 2 ] != '/' ) { str . appendRight ( node . end - 1 , '/' ) ; } } if ( htmlx [ node . end - 1 ] != '>' ) { str . appendRight ( node . end , `</${ node . name }>` ) ; } }