Skip to content

Commit bb0238d

Browse files
committed
Fix unquoted, tight, self-closing elements
remarkjs/remark-gfm#23
1 parent 62fa2f0 commit bb0238d

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

lib/tree.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export function element(ctx, node, index, parent) {
112112
if (
113113
!ctx.tightClose ||
114114
last === '/' ||
115-
(schema.space === 'svg' && last && last !== '"' && last !== "'")
115+
(last && last !== '"' && last !== "'")
116116
) {
117117
parts.push(' ')
118118
}

test/element.js

+12-3
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,24 @@ test('`element`', (t) => {
3535
'should serialize voids with `/` in `closeSelfClosing` and `tightSelfClosing` mode'
3636
)
3737

38-
// This works in a browser. The `/` is not part of the `[src]`.
38+
t.deepEqual(
39+
toHtml(h('input', {type: 'checkbox'}), {
40+
preferUnquoted: true,
41+
tightSelfClosing: true,
42+
closeSelfClosing: true
43+
}),
44+
'<input type=checkbox />',
45+
'should serialize voids with `/` in `closeSelfClosing` and `tightSelfClosing` mode, w/ space after an unquoted attribute (1)'
46+
)
47+
3948
t.deepEqual(
4049
toHtml(h('img', {src: 'index.jpg'}), {
4150
preferUnquoted: true,
4251
closeSelfClosing: true,
4352
tightSelfClosing: true
4453
}),
45-
'<img src=index.jpg/>',
46-
'should serialize voids with `/` in `closeSelfClosing` and `tightSelfClosing` mode, without space after an unquoted attribute'
54+
'<img src=index.jpg />',
55+
'should serialize voids with `/` in `closeSelfClosing` and `tightSelfClosing` mode, w/ space after an unquoted attribute (2)'
4756
)
4857

4958
t.deepEqual(

0 commit comments

Comments
 (0)