Skip to content

Commit 19ab379

Browse files
authored
Merge pull request #55 from posthtml/milestone-2.0.2
Milestone 2.0.2
2 parents 33318e2 + bcbdc60 commit 19ab379

File tree

5 files changed

+20
-6
lines changed

5 files changed

+20
-6
lines changed

changelog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1+
## <small>2.0.2 (2021-06-03)</small>
2+
3+
* fix: concate single tag ([a6764cf](https://github.com/posthtml/posthtml-render/commit/a6764cf))
4+
* test: fix only one test ([60f598d](https://github.com/posthtml/posthtml-render/commit/60f598d))
5+
6+
7+
18
## <small>2.0.1 (2021-05-24)</small>
29

10+
* 2.0.1 ([feb426c](https://github.com/posthtml/posthtml-render/commit/feb426c))
311
* ci: drop support old node ([810c46c](https://github.com/posthtml/posthtml-render/commit/810c46c))
412
* ci: lock ([3c894d6](https://github.com/posthtml/posthtml-render/commit/3c894d6))
513
* build: add prepare script, close #53 ([dbc9b47](https://github.com/posthtml/posthtml-render/commit/dbc9b47)), closes [#53](https://github.com/posthtml/posthtml-render/issues/53)

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "posthtml-render",
3-
"version": "2.0.1",
3+
"version": "2.0.2",
44
"description": "Renders PostHTML Tree to HTML/XML",
55
"license": "MIT",
66
"repository": "posthtml/posthtml-render",

src/index.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ type Node = NodeText | NodeTag & {
55
closeAs?: closingSingleTagTypeEnum;
66
};
77

8-
const SINGLE_TAGS = [
8+
const SINGLE_TAGS: Array<string | RegExp> = [
99
'area',
1010
'base',
1111
'br',
@@ -28,17 +28,23 @@ const SINGLE_TAGS = [
2828
const ATTRIBUTE_QUOTES_REQUIRED = /[\t\n\f\r "'`=<>]/;
2929

3030
const defaultOptions = {
31-
singleTags: SINGLE_TAGS,
3231
closingSingleTag: undefined,
3332
quoteAllAttributes: true,
3433
replaceQuote: true,
3534
quoteStyle: quoteStyleEnum.Double
3635
};
3736

3837
function render(tree?: Node | Node[], options: Options = {}): string {
38+
let st = SINGLE_TAGS;
39+
40+
if (options.singleTags) {
41+
st = [...new Set([...SINGLE_TAGS, ...options.singleTags])];
42+
}
43+
3944
options = {
4045
...defaultOptions,
41-
...options
46+
...options,
47+
singleTags: st
4248
};
4349

4450
const {

test/test-core.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ test('{Tree} {Empty}', t => {
188188
t.is(render(), '');
189189
});
190190

191-
test.only('{Tree} {String Template}', t => {
191+
test('{Tree} {String Template}', t => {
192192
const html = `
193193
<div>String Template</div>
194194
`;

0 commit comments

Comments
 (0)