From 074bfdc8f7d12a9950bceb0967fff71b260bc019 Mon Sep 17 00:00:00 2001 From: Henry Bley-Vroman Date: Fri, 10 Jan 2025 13:39:17 -1000 Subject: [PATCH] docs: parse() always adds a wrapper node #285 --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index eec87c9..dae41c1 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ import { parse } from 'node-html-parser'; const root = parse(''); +// parse() adds a wrapper node, so the input data's first node is the root's first child node console.log(root.firstChild.structure); // ul#list // li @@ -74,7 +75,7 @@ var root = HTMLParser.parse(''); ### parse(data[, options]) -Parse the data provided, and return the root of the generated DOM. +Parse the data provided, wrap the result in a new node, and return the root of the generated DOM. - **data**, data to parse - **options**, parse options @@ -349,11 +350,11 @@ Get all child elements, so all child nodes of type HTMLELement. ### firstChild -Get first child node. `undefined` if the node has no children. +Get first child node of the wrapper node added by `parse()`. `undefined` if the node has no children. ### lastChild -Get last child node. `undefined` if the node has no children. +Get last child node of the wrapper node added by `parse()`. `undefined` if the node has no children. ### firstElementChild