cgross / grunt-dom-munger

Grunt task to read and manipulate HTML with CSS selectors.
MIT License
93 stars 40 forks source link

Html elements replaced automatically #31

Open jyoung913 opened 9 years ago

jyoung913 commented 9 years ago
I have a html file in a web project, part of it reads something like:
<body>
<div>
<h4>something</h5><span>something else</span>
</div>

<div>
    something I want to modify
</div>
</body>

Note that h4-h5 mistake, it has been there for a long time and browsers seem to render it correctly.

Yesterday I added dom_munger to my GruntScript in order to select and modify some elements in the same page, something in another <div> as you see at the bottom. However by running the task,  dom_munger replaced the h4-h5 block to something like this:

<h4>something<span>something else</span></h4>

I am very certain that it is dom_munger that changed the tag, since it is the only npm task I added to build process. I want to know the reason behind this, does the selector assume that the html is written completely correctly? Or it tries to correct the html for me before selecting anything?