Skip to content

Don't auto change to svg namespace when in foreign namespace #6261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/compiler/compile/nodes/Element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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: `
<page horizontalAlignment="center">
<button textWrap="true" text="button">
<button textWrap="true" text="button"></button>
<text wordWrap="true"></text>
</page>
`,
options: {
Expand All @@ -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');
}
};
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<page horizontalAlignment="center">
<button textWrap="true" text="button">
</page>
<button textWrap="true" text="button" />
<text wordWrap="true" />
</page>