Skip to content

Commit 8ab487b

Browse files
committed
Emit /> instead of /> when closing SVG empty elements
For consistency with XMLSerializer, only void XHTML elements should have a space. Ideally such change should also be applied on other XML documents, but trying here to keep things simple.
1 parent 64b65b0 commit 8ab487b

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

cjs/interface/element.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ class Element extends ParentNode {
459459
const start = next[START];
460460
if (isOpened) {
461461
if ('ownerSVGElement' in start)
462-
out.push(' />');
462+
out.push('/>');
463463
else if (isVoid(start))
464464
out.push(ignoreCase(start) ? '>' : ' />');
465465
else

esm/interface/element.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ export class Element extends ParentNode {
461461
const start = next[START];
462462
if (isOpened) {
463463
if ('ownerSVGElement' in start)
464-
out.push(' />');
464+
out.push('/>');
465465
else if (isVoid(start))
466466
out.push(ignoreCase(start) ? '>' : ' />');
467467
else

test/shared/parse-json.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ let div = parseJSON('[1,"div",1,"svg",1,"rect",-2,1,"c-e",-2]');
3535

3636
assert(JSON.stringify(toJSON(div)), '[1,"div",1,"svg",1,"rect",-2,1,"c-e",-2]');
3737

38-
assert(div.toString(), '<div><svg><rect /></svg><c-e></c-e></div>');
38+
assert(div.toString(), '<div><svg><rect/></svg><c-e></c-e></div>');
3939

4040
assert(div.querySelector('c-e').constructed, void 0, 'not constructed');
4141

test/svg/element.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ assert(svg instanceof SVGElement, true, '<svg> is an instance of a facade');
1616
assert('ownerSVGElement' in svg, true, '<svg> ownerSVGElement');
1717
assert(svg.ownerSVGElement, null, '<svg> ownerSVGElement is null');
1818
assert(svg.firstChild.ownerSVGElement, svg, '<rect> has an ownerSVGElement');
19-
assert(document.toString(), '<div><svg><rect /></svg></div>', 'svg nodes are OK');
20-
assert(document.documentElement.cloneNode(true).outerHTML, '<div><svg><rect /></svg></div>', 'svg cloned');
19+
assert(document.toString(), '<div><svg><rect/></svg></div>', 'svg nodes are OK');
20+
assert(document.documentElement.cloneNode(true).outerHTML, '<div><svg><rect/></svg></div>', 'svg cloned');
2121

2222
assert(JSON.stringify(document), '[9,1,"div",1,"svg",1,"rect",-4]');
2323
assert(JSON.stringify(svg), '[1,"svg",1,"rect",-2]');
@@ -39,11 +39,11 @@ assert(svg.className.what, 'ever', '<svg>.className');
3939
svg.setAttribute('test', 123);
4040
svg.setAttribute('style', 'width:100px');
4141

42-
assert(svg.toString(), '<svg style="width:100px" test="123"><rect /></svg>');
42+
assert(svg.toString(), '<svg style="width:100px" test="123"><rect/></svg>');
4343

4444
svg.className = 'a b c';
4545
assert(svg.getAttribute('class'), 'a b c');
4646

4747
svg.setAttribute('class', 'd e');
4848
assert(svg.getAttribute('class'), 'd e');
49-
assert(svg.namespaceURI, 'http://www.w3.org/2000/svg');
49+
assert(svg.namespaceURI, 'http://www.w3.org/2000/svg');

test/worker.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import createAssert from './assert-es.js';
33

44
const assert = createAssert.for('Web Worker');
55

6-
let {document} = parseHTML('<div><svg><rect /></svg></div>');
6+
let {document} = parseHTML('<div><svg><rect/></svg></div>');
77

8-
assert(document.querySelector('div').firstChild.localName, 'svg', 'Should be an svg element in the div');
8+
assert(document.querySelector('div').firstChild.localName, 'svg', 'Should be an svg element in the div');

worker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8046,7 +8046,7 @@ let Element$1 = class Element extends ParentNode {
80468046
const start = next[START];
80478047
if (isOpened) {
80488048
if ('ownerSVGElement' in start)
8049-
out.push(' />');
8049+
out.push('/>');
80508050
else if (isVoid(start))
80518051
out.push(ignoreCase(start) ? '>' : ' />');
80528052
else

0 commit comments

Comments
 (0)