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

Fix hasSingleTagInsideElement method #88

Merged
merged 1 commit into from
Mar 19, 2024
Merged

Conversation

jtojnar
Copy link
Contributor

@jtojnar jtojnar commented Mar 16, 2024

It would fail for e.g. <div> <p>foo</p> </div>.

mozilla/readability uses children for the tag lookup, which return only elements. PHP does not have children property so b580cf2 mistakenly used childNodes instead, but that can return any node type.

Let’s filter the children ourselves.

Also add comments from mozilla/readability’s _hasSingleTagInsideElement.

Picked from #87

It would fail for e.g. `<div> <p>foo</p> </div>`.

mozilla/readability uses children for the tag lookup, which return only elements.
PHP does not have children property so b580cf2
mistakenly used `childNodes` instead, but that can return any node type.

Let’s filter the children ourselves.

Also add comments from mozilla/readability’s `_hasSingleTagInsideElement`.
@j0k3r j0k3r merged commit cb6b6ac into j0k3r:master Mar 19, 2024
9 checks passed
@jtojnar jtojnar deleted the has-single-fix branch March 19, 2024 09:36
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

Successfully merging this pull request may close these issues.

2 participants