[Doc] Clarify wrapper behaviour of parse() #287
Replies: 5 comments
-
I found another bug using my workaround: it seems to nest another div around everything. I think there are a lot of bugs to find using similar patterns to the above. |
Beta Was this translation helpful? Give feedback.
-
const root = parse(html);
root.querySelector('div').childNodes.unshift(parse('<p>a</p>').firstChild); |
Beta Was this translation helpful? Give feedback.
-
I don't understand why I need to do that Regardless, finding a part of HTML and modifying it (or its neighbors) seems like a common use case. Can the readme be updated to show examples of this use case? I don't know if you would prefer another issue for this, or for me to change the title of this one. Let me know. |
Beta Was this translation helpful? Give feedback.
-
The root node is not really a node, it is a container of all the |
Beta Was this translation helpful? Give feedback.
-
The node in question is a wrapper node. It is a commonly used pattern for html parsers, however, I think it makes sense to add something to the readme which explains the behaviour of If you want to change the issue title, I'll reopen if @taoqf is amenable to my doing a PR that clarifies that bit in the readme. |
Beta Was this translation helpful? Give feedback.
-
Here is a failing test case:
My workaround was to use
childNodes[0].set_content(newContent + oldContent)
.The reason I wrote this code in the first place is because I couldn't figure out from the documentation how to prepend content. I looked at the tests and noticed some of them were using
childNodes[0]
and figured, if you can index that array, you should be able to call other functions on it and have it work.Beta Was this translation helpful? Give feedback.
All reactions