html-differ icon indicating copy to clipboard operation
html-differ copied to clipboard

Self-closing elements should be equivalent

Open i-like-robots opened this issue 9 years ago • 0 comments

Currently optionally self-closing elements such as images and line breaks are not considered equivalent. E.G.

const differ = require('html-differ')

let lhs = '<div><br></div>'
let rhs = '<div><br /></div>'

let diff = differ.diffHtml(lhs, rhs) 

console.log(diff)

// [
//   {
//     "value": "<div><br"
//   },
//   {
//     "value": "/",
//     "added": true
//   },
//   {
//     "value": "></div>"
//   }
// ]

For reference Parse5 and htmlparser2 interpret both strings equally. I'm looking into this to see if I can help.

i-like-robots avatar Jan 25 '16 17:01 i-like-robots