Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small typo in documentation #289

Open
edoardo-bluframe opened this issue Feb 16, 2025 · 0 comments
Open

Small typo in documentation #289

edoardo-bluframe opened this issue Feb 16, 2025 · 0 comments

Comments

@edoardo-bluframe
Copy link

Docs say

import { parse } from 'node-html-parser';

const root = parse('<ul id="list"><li>Hello World</li></ul>');

console.log(root.firstChild.structure);
// ul#list
//   li
//     #text

console.log(root.querySelector('#list'));
// { tagName: 'ul',
//   rawAttrs: 'id="list"',
//   childNodes:
//    [ { tagName: 'li',
//        rawAttrs: '',
//        childNodes: [Object],
//        classNames: [] } ],
//   id: 'list',
//   classNames: [] }
console.log(root.toString());
// <ul id="list"><li>Hello World</li></ul>
root.set_content('<li>Hello World</li>');
root.toString();	// <li>Hello World</li>

We are moving from JSDOM to this - a lot faster - and initial we changed all our tagName matches to lowercase as the examples shows lowercase: tagName: 'ul'

We realized it wasn't working and that it was in fact returning UL just like JSDOM

Later in the docs it does specify Get or Set tag name of HTMLElement. Note that the returned value is an uppercase string.

Isn't it better if the example - which is at the very top and one of the first things we read - actually matches functionality? 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant