@ -5,6 +5,7 @@ import {
regex _whitespaces _strict
regex _whitespaces _strict
} from '../patterns.js' ;
} from '../patterns.js' ;
import * as b from '../../utils/builders.js' ;
import * as b from '../../utils/builders.js' ;
import { walk } from 'zimmerframe' ;
/ * *
/ * *
* @ param { string } s
* @ param { string } s
@ -249,51 +250,49 @@ export function infer_namespace(namespace, parent, nodes, path) {
* @ param { import ( '#compiler' ) . Namespace | 'keep' | 'maybe_html' } namespace
* @ param { import ( '#compiler' ) . Namespace | 'keep' | 'maybe_html' } namespace
* /
* /
function check _nodes _for _namespace ( nodes , namespace ) {
function check _nodes _for _namespace ( nodes , namespace ) {
/ * *
* @ param { import ( '#compiler' ) . SvelteElement | import ( '#compiler' ) . RegularElement } node }
* @ param { { stop : ( ) => void } } context
* /
const RegularElement = ( node , { stop } ) => {
if ( ! node . metadata . svg ) {
namespace = 'html' ;
stop ( ) ;
} else if ( namespace === 'keep' ) {
namespace = 'svg' ;
}
} ;
for ( const node of nodes ) {
for ( const node of nodes ) {
if ( node . type === 'RegularElement' || node . type === 'SvelteElement' ) {
walk (
if ( ! node . metadata . svg ) {
node ,
namespace = 'html' ;
{ } ,
break ;
{
} else if ( namespace === 'keep' ) {
_ ( node , { next } ) {
namespace = 'svg' ;
if (
}
node . type === 'EachBlock' ||
} else if (
node . type === 'IfBlock' ||
( node . type === 'Text' && node . data . trim ( ) !== '' ) ||
node . type === 'AwaitBlock' ||
node . type === 'HtmlTag' ||
node . type === 'Fragment' ||
node . type === 'RenderTag'
node . type === 'KeyBlock' ||
) {
node . type === 'RegularElement' ||
namespace = 'maybe_html' ;
node . type === 'SvelteElement' ||
} else if ( node . type === 'EachBlock' ) {
node . type === 'Text'
namespace = check _nodes _for _namespace ( node . body . nodes , namespace ) ;
) {
if ( namespace === 'html' ) break ;
next ( ) ;
if ( node . fallback ) {
}
namespace = check _nodes _for _namespace ( node . fallback . nodes , namespace ) ;
} ,
if ( namespace === 'html' ) break ;
SvelteElement : RegularElement ,
}
RegularElement ,
} else if ( node . type === 'IfBlock' ) {
Text ( node ) {
namespace = check _nodes _for _namespace ( node . consequent . nodes , namespace ) ;
if ( node . data . trim ( ) !== '' ) {
if ( namespace === 'html' ) break ;
namespace = 'maybe_html' ;
if ( node . alternate ) {
}
namespace = check _nodes _for _namespace ( node . alternate . nodes , namespace ) ;
}
if ( namespace === 'html' ) break ;
}
} else if ( node . type === 'AwaitBlock' ) {
if ( node . pending ) {
namespace = check _nodes _for _namespace ( node . pending . nodes , namespace ) ;
if ( namespace === 'html' ) break ;
}
}
if ( node . then ) {
) ;
namespace = check _nodes _for _namespace ( node . then . nodes , namespace ) ;
if ( namespace === 'html' ) break ;
if ( namespace === 'html' ) return namespace ;
}
if ( node . catch ) {
namespace = check _nodes _for _namespace ( node . catch . nodes , namespace ) ;
if ( namespace === 'html' ) break ;
}
} else if ( node . type === 'KeyBlock' ) {
namespace = check _nodes _for _namespace ( node . fragment . nodes , namespace ) ;
if ( namespace === 'html' ) break ;
}
}
}
return namespace ;
return namespace ;