-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
root will be overwritten #1706
root will be overwritten #1706
Conversation
@5saviahv This is yet another great PR. I have one question about this, otherwise it should have been pretty much good to go. |
My doubts were mainly if context is provided and is object - do I have to add some more testing there ? |
Co-authored-by: Felix Böhm <me@feedic.com>
@@ -53,7 +53,7 @@ var Cheerio = (module.exports = function (selector, context, root, options) { | |||
|
|||
if (root) { | |||
if (typeof root === 'string') root = parse(root, this.options, false); | |||
this._root = Cheerio.call(this, root); | |||
this._root = new Cheerio(root); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally figured out what's wrong here: This should be new this.constructor(root)
. Incorporating this in a different PR.
Co-Authored-By: 5saviahv <49443574+5saviahv@users.noreply.github.com>
root will be overwritten if you parse new html content.
lets say you
turns out since
el._root
&el
are same instance. if you adddiv
into dom you effectively overwritingroot
. Now when you plan make query against that old root you get empty results since new emptydiv
wont have old content.