@@ -125,24 +125,6 @@ function defaultBuildScopeSelector(compId: string): string {
125125 return `[data-composition-id="${ escaped } "]` ;
126126}
127127
128- function emptyCompositionHtmlError ( src : string ) : Error {
129- return new Error (
130- `Composition HTML is empty or could not be parsed: ${ src } . Check that the file referenced by data-composition-src contains valid HTML.` ,
131- ) ;
132- }
133-
134- function assertNonEmptyCompositionHtml ( html : string , src : string ) : void {
135- if ( ! html . trim ( ) ) {
136- throw emptyCompositionHtmlError ( src ) ;
137- }
138- }
139-
140- function assertParsedCompositionDocument ( doc : Document , src : string ) : void {
141- if ( ! doc . documentElement ) {
142- throw emptyCompositionHtmlError ( src ) ;
143- }
144- }
145-
146128// ---------------------------------------------------------------------------
147129// Core implementation
148130// ---------------------------------------------------------------------------
@@ -194,16 +176,16 @@ export function inlineSubCompositions(
194176 if ( ! src ) continue ;
195177
196178 const compHtml = resolveHtml ( src ) ;
197- if ( compHtml == null ) {
198- if ( onMissingComposition ) {
199- onMissingComposition ( src ) ;
200- }
179+ if ( compHtml == null || ! compHtml . trim ( ) ) {
180+ onMissingComposition ?.( src ) ;
201181 continue ;
202182 }
203183
204- assertNonEmptyCompositionHtml ( compHtml , src ) ;
205184 const compDoc = parseHtml ( compHtml ) ;
206- assertParsedCompositionDocument ( compDoc , src ) ;
185+ if ( ! compDoc . documentElement ) {
186+ onMissingComposition ?.( src ) ;
187+ continue ;
188+ }
207189
208190 // Determine composition IDs
209191 let compId : string | null ;
@@ -220,9 +202,15 @@ export function inlineSubCompositions(
220202 // Find content: prefer <template>, fall back to <body>
221203 const contentRoot = compDoc . querySelector ( "template" ) ;
222204 const contentHtml = contentRoot ? contentRoot . innerHTML || "" : compDoc . body ?. innerHTML || "" ;
223- assertNonEmptyCompositionHtml ( contentHtml , src ) ;
205+ if ( ! contentHtml . trim ( ) ) {
206+ onMissingComposition ?.( src ) ;
207+ continue ;
208+ }
224209 const contentDoc = parseHtml ( contentHtml ) ;
225- assertParsedCompositionDocument ( contentDoc , src ) ;
210+ if ( ! contentDoc . documentElement ) {
211+ onMissingComposition ?.( src ) ;
212+ continue ;
213+ }
226214
227215 // Find the inner composition root
228216 const innerRoot = compId
0 commit comments