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

$element->each() -> create new DomQuery -> children() -> wrong results. #40

Closed
silverham opened this issue Mar 21, 2022 · 0 comments
Closed

Comments

@silverham
Copy link

use Rct567\DomQuery\DomQuery;
$dom = new DomQuery('<div><p class="myclass"><span>My words</span></p></div>');

var_dump((string) $dom->find('p')->children());
// Dumps: '<span>My words</span>' - CORRECT.

$dom->find('p')->each(function($node) use ($dom) {
  var_dump((string) DomQuery::create($node)->children());
  // Dumps: '<div><p class="myclass"><span>My words</span></p></div>' - WRONG.
 
  // Workaround.
  var_dump((string) $dom->find($node)->children());
  // Dumps: '<span>My words</span>' - CORRECT.
});
@Rct567 Rct567 closed this as completed in 20e2e25 Jan 18, 2024
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

1 participant