Skip to content

Commit

Permalink
fix: issue #109
Browse files Browse the repository at this point in the history
  • Loading branch information
taoqf committed Apr 6, 2021
1 parent 578e365 commit acb31ab
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/nodes/html.ts
Expand Up @@ -269,7 +269,7 @@ export default class HTMLElement extends Node {
if (tag) {
// const void_tags = new Set('area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr'.split('|'));
// const is_void = void_tags.has(tag);
const is_void = /area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr/i.test(tag);
const is_void = /^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/i.test(tag);
const attrs = this.rawAttrs ? ` ${this.rawAttrs}` : '';
if (is_void) {
return `<${tag}${attrs}>`;
Expand Down
14 changes: 14 additions & 0 deletions test/109.js
@@ -0,0 +1,14 @@
const { parse } = require('../dist');

describe('self-close tag', function () {
it('should not teat textarea as self-colse tag', async function () {
const html = '<textarea id="input_3"></textarea>';
const root = parse(html);
root.toString().should.eql(html);
});
it('inptu is self-closing', async function () {
const html = '<input value="foo" />';
const root = parse(html);
root.toString().should.eql('<input value="foo" >');
});
});

0 comments on commit acb31ab

Please sign in to comment.