diff --git a/src/compiler/compile/nodes/Element.ts b/src/compiler/compile/nodes/Element.ts
index 77cb2e062d..c9529fcbcb 100644
--- a/src/compiler/compile/nodes/Element.ts
+++ b/src/compiler/compile/nodes/Element.ts
@@ -107,8 +107,10 @@ function get_namespace(parent: Element, element: Element, explicit_namespace: st
: null);
}
- if (svg.test(element.name.toLowerCase())) return namespaces.svg;
- if (parent_element.name.toLowerCase() === 'foreignobject') return null;
+ if (parent_element.namespace !== namespaces.foreign) {
+ if (svg.test(element.name.toLowerCase())) return namespaces.svg;
+ if (parent_element.name.toLowerCase() === 'foreignobject') return null;
+ }
return parent_element.namespace;
}
diff --git a/test/runtime/samples/attribute-casing-foreign-namespace-compiler-option/_config.js b/test/runtime/samples/attribute-casing-foreign-namespace-compiler-option/_config.js
index 1225c64fc2..0439aca06a 100644
--- a/test/runtime/samples/attribute-casing-foreign-namespace-compiler-option/_config.js
+++ b/test/runtime/samples/attribute-casing-foreign-namespace-compiler-option/_config.js
@@ -1,9 +1,11 @@
-// Test support for the `foreign` namespace preserving attribute case.
+// Test support for the `foreign` namespace preserving attribute case,
+// including ensuring that SVG elements don't interfere.
export default {
html: `
-
`,
options: {
@@ -16,5 +18,6 @@ export default {
const attr = sel => target.querySelector(sel).attributes[0].name;
assert.equal(attr('page'), 'horizontalAlignment');
assert.equal(attr('button'), 'textWrap');
+ assert.equal(attr('text'), 'wordWrap');
}
};
diff --git a/test/runtime/samples/attribute-casing-foreign-namespace-compiler-option/main.svelte b/test/runtime/samples/attribute-casing-foreign-namespace-compiler-option/main.svelte
index 6300ab3b63..52b3e646e1 100644
--- a/test/runtime/samples/attribute-casing-foreign-namespace-compiler-option/main.svelte
+++ b/test/runtime/samples/attribute-casing-foreign-namespace-compiler-option/main.svelte
@@ -1,3 +1,4 @@
-
-
\ No newline at end of file
+
+
+