Rct567/DomQuery

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

silverham opened this issue · 0 comments

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.
});