Skip to content

Fix hasSingleTagInsideElement method - #88

Merged
j0k3r merged 1 commit into
j0k3r:masterfrom
jtojnar:has-single-fix
Mar 19, 2024
Merged

Fix hasSingleTagInsideElement method#88
j0k3r merged 1 commit into
j0k3r:masterfrom
jtojnar:has-single-fix

Conversation

@jtojnar

@jtojnar jtojnar commented Mar 16, 2024

Copy link
Copy Markdown
Collaborator

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
@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