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

pull/6271/head
halfnelson 4 years ago committed by GitHub
parent a39fc8de72
commit 4633697214
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -107,8 +107,10 @@ function get_namespace(parent: Element, element: Element, explicit_namespace: st
: null); : null);
} }
if (svg.test(element.name.toLowerCase())) return namespaces.svg; if (parent_element.namespace !== namespaces.foreign) {
if (parent_element.name.toLowerCase() === 'foreignobject') return null; if (svg.test(element.name.toLowerCase())) return namespaces.svg;
if (parent_element.name.toLowerCase() === 'foreignobject') return null;
}
return parent_element.namespace; return parent_element.namespace;
} }

@ -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 { export default {
html: ` html: `
<page horizontalAlignment="center"> <page horizontalAlignment="center">
<button textWrap="true" text="button"> <button textWrap="true" text="button"></button>
<text wordWrap="true"></text>
</page> </page>
`, `,
options: { options: {
@ -16,5 +18,6 @@ export default {
const attr = sel => target.querySelector(sel).attributes[0].name; const attr = sel => target.querySelector(sel).attributes[0].name;
assert.equal(attr('page'), 'horizontalAlignment'); assert.equal(attr('page'), 'horizontalAlignment');
assert.equal(attr('button'), 'textWrap'); assert.equal(attr('button'), 'textWrap');
assert.equal(attr('text'), 'wordWrap');
} }
}; };

@ -1,3 +1,4 @@
<page horizontalAlignment="center"> <page horizontalAlignment="center">
<button textWrap="true" text="button"> <button textWrap="true" text="button" />
</page> <text wordWrap="true" />
</page>

Loading…
Cancel
Save