taoqf / node-html-parser

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

node.tagName is suddenly uppercase in 1.2.21 #76

Closed andyhasit closed 3 years ago

andyhasit commented 3 years ago

In version 1.2.20 node.tagName comes back lowercase:

> ht = require('node-html-parser')
> d = ht.parse('<div></div>')
> d.childNodes[0].tagName
'div'

In version 1.2.21 node.tagName comes back uppercase:

> ht = require('node-html-parser')
> d = ht.parse('<div></div>')
> d.childNodes[0].tagName
'DIV'

Patch versions past v1 must not introduce breaking changes like this! It means any tool/project/framework which:

  1. Uses node-html-parser at v 1.2.x (e.g. "node-html-parser": "^1.2.8")
  2. Relies on the case of tag names (e.g. to differentiate between <standard-html-tags> and <CustomComponentClassTags/> like React)

Is now broken for all installs after 25th August.

We need a 1.2.22 release which fixes this bug ASAP.

andyhasit commented 3 years ago

I would take a stab at fixing it, but looking here there seems to be a deliberate switch to uppercase? https://github.com/taoqf/node-html-parser/commit/5bbd878acd0ad2db90752e12b276d63bdcd90615

taoqf commented 3 years ago

@andyhasit Yes, it's a break change, so I deprecated 1.2.21 and published 1.3. I change tagName to uppercase because you will find the same behavior in browser chrome.