only use explicit namespace for top-level elements

pull/2372/head
Richard Harris 6 years ago
parent af1315b438
commit 4177af8d59

@ -73,13 +73,13 @@ const passive_events = new Set([
'touchcancel' 'touchcancel'
]); ]);
function get_namespace(parent: Element, element: Element) { function get_namespace(parent: Element, element: Element, explicit_namespace: string) {
const parent_element = parent.find_nearest(/^Element/); const parent_element = parent.find_nearest(/^Element/);
if (!parent_element) { if (!parent_element) {
return svg.test(element.name) return explicit_namespace || (svg.test(element.name)
? namespaces.svg ? namespaces.svg
: null; : null);
} }
if (element.name.toLowerCase() === 'svg') return namespaces.svg; if (element.name.toLowerCase() === 'svg') return namespaces.svg;
@ -108,7 +108,7 @@ export default class Element extends Node {
super(component, parent, scope, info); super(component, parent, scope, info);
this.name = info.name; this.name = info.name;
this.namespace = component.namespace || get_namespace(parent, this); this.namespace = get_namespace(parent, this, component.namespace);
if (this.name === 'textarea') { if (this.name === 'textarea') {
if (info.children.length > 0) { if (info.children.length > 0) {

Loading…
Cancel
Save