diff --git a/src/compile/nodes/Element.ts b/src/compile/nodes/Element.ts index 6d9c8059f5..a76a01e3b4 100644 --- a/src/compile/nodes/Element.ts +++ b/src/compile/nodes/Element.ts @@ -94,16 +94,11 @@ export default class Element extends Node { this.name = info.name; const parent_element = parent.find_nearest(/^Element/); - this.namespace = this.name === 'svg' ? - namespaces.svg : - parent_element ? parent_element.namespace : this.component.namespace; - - if (!this.namespace && svg.test(this.name)) { - this.component.warn(this, { - code: `missing-namespace`, - message: `<${this.name}> is an SVG element – did you forget to add ?` - }); - } + this.namespace = this.name === 'svg' || (!parent_element && svg.test(this.name)) + ? namespaces.svg + : this.name === 'foreignObject' + ? namespaces.html + : parent_element ? parent_element.namespace : this.component.namespace; if (this.name === 'textarea') { if (info.children.length > 0) { diff --git a/test/runtime/samples/svg-foreignobject-namespace/_config.js b/test/runtime/samples/svg-foreignobject-namespace/_config.js new file mode 100644 index 0000000000..a0185bae8e --- /dev/null +++ b/test/runtime/samples/svg-foreignobject-namespace/_config.js @@ -0,0 +1,14 @@ +export default { + html: ` + + +

some text

+
+
+ `, + + test({ assert, target }) { + const p = target.querySelector('p'); + assert.equal(p.namespaceURI, 'http://www.w3.org/1999/xhtml'); + } +}; diff --git a/test/runtime/samples/svg-foreignobject-namespace/main.svelte b/test/runtime/samples/svg-foreignobject-namespace/main.svelte new file mode 100644 index 0000000000..e841e0d417 --- /dev/null +++ b/test/runtime/samples/svg-foreignobject-namespace/main.svelte @@ -0,0 +1,5 @@ + + +

some text

+
+
diff --git a/test/validator/samples/svg-child-component-undeclared-namespace/input.svelte b/test/validator/samples/svg-child-component-undeclared-namespace/input.svelte deleted file mode 100644 index b4b6fc86d7..0000000000 --- a/test/validator/samples/svg-child-component-undeclared-namespace/input.svelte +++ /dev/null @@ -1,8 +0,0 @@ - - - \ No newline at end of file diff --git a/test/validator/samples/svg-child-component-undeclared-namespace/warnings.json b/test/validator/samples/svg-child-component-undeclared-namespace/warnings.json deleted file mode 100644 index 128b8628ed..0000000000 --- a/test/validator/samples/svg-child-component-undeclared-namespace/warnings.json +++ /dev/null @@ -1,15 +0,0 @@ -[{ - "code": "missing-namespace", - "message": " is an SVG element – did you forget to add ?", - "start": { - "line": 8, - "column": 0, - "character": 89 - }, - "end": { - "line": 8, - "column": 49, - "character": 138 - }, - "pos": 89 -}]