cheeriojs/cheerio

`html` isn't the root of the document

fb55 opened this issue · 5 comments

fb55 commented

fb55/css-select#8 should be handled here. The issue is that selectors such as * html match elements. This won't be fixed in CSSselect, so I'm moving it here.

I'm running into this issue. I'm trying to write code that's portable between jQuery and cheerio; and it's becoming difficult, because I can't find a portable and performant way to acquire the root element. Cheerio wants $.root(), whereas jQuery wants $(':root') or $(':eq(0)').

fb55 commented

@ELLIOTTCABLE How about $("html")? Some documents won't have it, but that shouldn't be too bad.

@fb55 that's what I'm doing right now, but I tend to want to write “correct” code. What I'm truly looking for here is to acquire the root of any document it may be processing, and that seems to be too hard-coded for my tastes. Make sense?

Either way, it's something worth fixing, even if there's a passable way around it like that.

Resolved via commit 7c07fac

fb55 commented

This actually isn't fixed. CSSselect's :root, as well as .root(), don't behave as expected.