taoqf / node-html-parser

A very fast HTML parser, generating a simplified DOM, with basic element query support.
MIT License
1.12k stars 112 forks source link

Custom void tags are not working #248

Closed zuozuomuxi closed 1 year ago

zuozuomuxi commented 1 year ago

Custom void tags must be written in a self-closing form to be parsed.

var { valid, parse }  = require("node-html-parser")

const voidTags = ['x-tag'];
const html1 = `<div><x-tag></div>`;
const html2 = `<div><x-tag /></div>`;

// => false. Expected to be true
console.log(valid(html1, {
  voidTag: {
    tags: voidTags,
  }
}));

// => true
console.log(valid(html2, {
  voidTag: {
    tags: voidTags,
  }
}));