Skip to content

Commit f1d81be

Browse files
authored
avoid adding double colon (#315)
* avoid adding double colon * Create beige-starfishes-worry.md
1 parent bd818dc commit f1d81be

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

.changeset/beige-starfishes-worry.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"preact-render-to-string": patch
3+
---
4+
5+
avoid adding double colon for namespaced attributes

src/util.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/;
22
export const UNSAFE_NAME = /[\s\n\\/='"\0<>]/;
3-
export const NAMESPACE_REPLACE_REGEX = /^(xlink|xmlns|xml)(:|[A-Z])/;
3+
export const NAMESPACE_REPLACE_REGEX = /^(xlink|xmlns|xml)([A-Z])/;
44
export const HTML_LOWER_CASE = /^accessK|^auto[A-Z]|^ch|^col|cont|cross|dateT|encT|form[A-Z]|frame|hrefL|inputM|maxL|minL|noV|playsI|readO|rowS|spellC|src[A-Z]|tabI|item[A-Z]/;
55
export const SVG_CAMEL_CASE = /^ac|^ali|arabic|basel|cap|clipPath$|clipRule$|color|dominant|enable|fill|flood|font|glyph[^R]|horiz|image|letter|lighting|marker[^WUH]|overline|panose|pointe|paint|rendering|shape|stop|strikethrough|stroke|text[^L]|transform|underline|unicode|units|^v[^i]|^w|^xH/;
66

test/render.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,12 @@ describe('render', () => {
337337
`<svg><image xlink:href="#"></image><foreignObject><div xlink:href="#"></div></foreignObject><g><image xlink:href="#"></image></g></svg>`
338338
);
339339
});
340+
341+
it('should not add extra colon on SVG elements', () => {
342+
let rendered = render(<svg>{h('image', { 'xlink:href': '#' })}</svg>);
343+
344+
expect(rendered).to.equal(`<svg><image xlink:href="#"></image></svg>`);
345+
});
340346
});
341347

342348
describe('Functional Components', () => {

0 commit comments

Comments
 (0)