Skip to content

Small typo in documentationΒ #289

@edoardo-bluframe

Description

@edoardo-bluframe

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? πŸ˜„

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions