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

feature request: setter for `.tagName` #176

Closed UltraCakeBakery closed 2 years ago

UltraCakeBakery commented 2 years ago

I need to change every <button> to <div aria-role="button">. This is currently very difficult to do as it requires me to create a new element, move it around and remove the old one.

UltraCakeBakery commented 2 years ago

I just looked into the source code and noticed that I can just change .rawTagName. Is this a safe thing to do?

taoqf commented 2 years ago

You can use the setter tagName v5.2.0 @nonara it seems v5.2.0 is not published after i pushed tag to github, help me.

nonara commented 2 years ago

You can use the setter tagName v5.2.0 @nonara it seems v5.2.0 is not published after i pushed tag to github, help me.

@taoqf Nice work with the new feature!

It looks like standard-version wouldn't be able to recognize the commits. standard-version updates the changelog and creates a tag when you run it, but it needs commit messages to be in the conventional commits style.

For example, in order to get the right changelog message, you could name the commits like this:

feat: added setter for tagName (feat: lets it know that it needs to bump the minor version, if it was just a patch, you'd use fix:) test: added tests for tagName setter docs: update readme

Then when you're ready to release, do the following:

  1. Build & test
  2. Execute the shell command standard-version (this will bump the version number, create a new release commit, and create a tag)
  3. Push tags + commits

After that, GitHub actions will create a new GH release and publish to npm for you.

Hope that helps!