Skip to content

Commit 3ab5e82

Browse files
committed
merge: from master
1 parent 9eaaca4 commit 3ab5e82

File tree

4 files changed

+9
-71
lines changed

4 files changed

+9
-71
lines changed

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ const html = render(tree, options)
8989
|**[`closingSingleTag`](#closingSingleTag)**|`{String}`|[`>`](#default)|Specify the single tag closing format|
9090
|**[`quoteAllAttributes`](#quoteAllAttributes)**|`{Boolean}`|[`true`](#default)|Put double quotes around all tags, even when not necessary.|
9191
|**[`replaceQuote`](#replaceQuote)**|`{Boolean}`|[`true`](#default)|Replaces quotes in attribute values with `&quote;`.|
92-
|**[`quoteStyle`](#quoteStyle)**|`{0|1|2}`|[`2`](#default)|Specify the style of quote arround the attribute values|
92+
|**[`quoteStyle`](#quoteStyle)**|`{0 or 1 or 2}`|[`2`](#default)|Specify the style of quote arround the attribute values|
9393

9494
### `singleTags`
9595

render.md

Lines changed: 0 additions & 63 deletions
This file was deleted.

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ function render(tree?: Node | Node[], options: Options = {}): string {
137137
return singleRegExp.some(reg => reg.test(tag));
138138
}
139139

140-
if (!singleTags?.includes(tag)) {
140+
if (!singleTags?.includes(tag.toLowerCase())) {
141141
return false;
142142
}
143143

test/test-core.spec.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,16 @@ test('{Tree} {Immutable}', t => {
203203
});
204204

205205
test('{Options} {singleTag} Defaults', t => {
206-
const SINGLE_TAGS = [
206+
const SINGLE_TAGS_LOWERCASE = [
207207
'area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr'
208208
];
209209

210+
const SINGLE_TAGS_UPPERCASE = [
211+
'IMG'
212+
];
213+
214+
const SINGLE_TAGS = SINGLE_TAGS_LOWERCASE.concat(SINGLE_TAGS_UPPERCASE);
215+
210216
t.is(
211217
render(SINGLE_TAGS.map(tag => ({tag}))),
212218
SINGLE_TAGS.map(tag => `<${tag}>`).join('')
@@ -339,7 +345,6 @@ test('{Options} {replaceQuote} replace quote', t => {
339345

340346
const fixture = {tag: 'img', attrs: {src: '<?php echo $foo["bar"] ?>'}};
341347
const expected = '<img src="<?php echo $foo["bar"] ?>">';
342-
fs.writeFileSync('test.html', render(fixture, options));
343348
t.is(render(fixture, options), expected);
344349
});
345350

@@ -348,7 +353,6 @@ test('{Options} {replaceQuote} replace quote ternary operator', t => {
348353

349354
const fixture = {tag: 'img', attrs: {src: '<?php echo isset($foo["bar"]) ? $foo["bar"] : ""; ?>'}};
350355
const expected = '<img src="<?php echo isset($foo["bar"]) ? $foo["bar"] : ""; ?>">';
351-
fs.writeFileSync('test.html', render(fixture, options));
352356
t.is(render(fixture, options), expected);
353357
});
354358

@@ -358,7 +362,6 @@ test('{Options} {quoteStyle} 1 - single quote', t => {
358362
const fixture = {tag: 'img', attrs: {src: 'https://example.com/example.png', onload: 'testFunc("test")'}};
359363
const expected = '<img src=\'https://example.com/example.png\' onload=\'testFunc("test")\'>';
360364

361-
fs.writeFileSync('test.html', render(fixture, options));
362365
t.is(render(fixture, options), expected);
363366
});
364367

@@ -368,7 +371,6 @@ test('{Options} {quoteStyle} 2 - double quote', t => {
368371
const fixture = {tag: 'img', attrs: {src: 'https://example.com/example.png', onload: 'testFunc("test")'}};
369372
const expected = '<img src="https://example.com/example.png" onload="testFunc("test")">';
370373

371-
fs.writeFileSync('test.html', render(fixture, options));
372374
t.is(render(fixture, options), expected);
373375
});
374376

@@ -378,6 +380,5 @@ test('{Options} {quoteStyle} 0 - smart quote', t => {
378380
const fixture = {tag: 'img', attrs: {src: 'https://example.com/example.png', onload: 'testFunc("test")'}};
379381
const expected = '<img src="https://example.com/example.png" onload=\'testFunc("test")\'>';
380382

381-
fs.writeFileSync('test.html', render(fixture, options));
382383
t.is(render(fixture, options), expected);
383384
});

0 commit comments

Comments
 (0)