Skip to content
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

DOMQuery::is() returns wrong results #198

Open
Code-Working opened this issue Nov 30, 2017 · 1 comment
Open

DOMQuery::is() returns wrong results #198

Code-Working opened this issue Nov 30, 2017 · 1 comment

Comments

@Code-Working
Copy link

Code-Working commented Nov 30, 2017

Hi,
I've just found a small bug while using the DOMQuery::is() method with a tag selector.

It seems as if the is() method does not check the matched element itself but all elements below the matched DOM query.

A simple code is this:

$document = html5qp('<a class="blubb" href="blabla"><span class="test"><img><div class="element">Text</div></span></a>');
var_dump($document->find('.element')->parent()->tag());
var_dump($document->find('.element')->parent()->first()->is('img'));

While looking at the code, you would expect a result like this:

string(4) "span"
bool(false)

But, the real result is this:

string(5) "span"
bool(true)

If you remove the <img> tag from the HTML code, it returns false, so this is why I'm guessing that the is() method is traversing through the DOM like the find() method.

Regards
Code-Working

@chx
Copy link

chx commented Mar 2, 2019

As a consequence closest which relies on is is completely broken as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants