Skip to content

Commit e3d9055

Browse files
committed
simplify
1 parent 88b5010 commit e3d9055

File tree

1 file changed

+8
-16
lines changed
  • packages/svelte/src/compiler/phases/3-transform

1 file changed

+8
-16
lines changed

packages/svelte/src/compiler/phases/3-transform/utils.js

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -346,29 +346,21 @@ export function infer_namespace(namespace, parent, nodes) {
346346
return new_namespace;
347347
}
348348
}
349-
const elements = nodes.filter((n) => n.type === 'RegularElement');
349+
350350
/** @type {Namespace | null} */
351351
let new_namespace = null;
352352

353353
// Check the elements within the fragment and look for consistent namespaces.
354354
// If we have no namespaces or they are mixed, then fallback to existing namespace
355-
for (const element of elements) {
356-
const metadata = element.metadata;
355+
for (const node of nodes) {
356+
if (node.type !== 'RegularElement') continue;
357357

358-
if (metadata.mathml) {
359-
if (new_namespace === null || new_namespace === 'mathml') {
360-
new_namespace = 'mathml';
361-
} else {
362-
new_namespace = 'html';
363-
}
364-
} else if (metadata.svg) {
365-
if (new_namespace === null || new_namespace === 'svg') {
366-
new_namespace = 'svg';
367-
} else {
368-
new_namespace = 'html';
369-
}
358+
if (node.metadata.mathml) {
359+
new_namespace = new_namespace === null || new_namespace === 'mathml' ? 'mathml' : 'html';
360+
} else if (node.metadata.svg) {
361+
new_namespace = new_namespace === null || new_namespace === 'svg' ? 'svg' : 'html';
370362
} else {
371-
new_namespace = 'html';
363+
return 'html';
372364
}
373365
}
374366

0 commit comments

Comments
 (0)