Closed allain closed 9 months ago
It appears that removing an attribute causes boolean attributes to be rendered incorrectly:
const {parse} = require("node-html-parser") const inputEl = parse('<input>').firstChild inputEl.setAttribute('checked', '') inputEl.setAttribute('a', '') console.log(inputEl.toString()) // => <input checked a> CORRECT inputEl.removeAttribute('a') console.log(inputEl.toString()) // => <input checked=""> INCORRECT
If it helps narrow it down, the bug does not happen if the boolean attribute was not added using setAttribute:
const {parse} = require("node-html-parser") const inputEl = parse('<input checked>').firstChild inputEl.setAttribute('a', '') console.log(inputEl.toString()) // => <input checked a> CORRECT inputEl.removeAttribute('a') console.log(inputEl.toString()) // => <input checked> CORRECT
It appears that removing an attribute causes boolean attributes to be rendered incorrectly:
If it helps narrow it down, the bug does not happen if the boolean attribute was not added using setAttribute: