Rct567/DomQuery

->each returns DOMElement instead of DomQuery

torian257x opened this issue ยท 3 comments

is that on purpose?

e.g. I cannot do

$dq->find('select[name="myname"]')->each(function ($el, $i){
            /** @var \DOMElement $el */
            $linktag = $el->parent(); //meeep parent doesn't exist on DOMElement

});

Yeh it is, see also: https://api.jquery.com/each/

If you want the result as an DomQuery instance you can just use a foreach loop.

@Rct567 ahh thanks
well in jquery you can do

->each(function(el){
var jel = $(el);
jel.parent();
});

is there something equivalent?

The constructor also accepts DOMNode/DOMElement, so just use new DomQuery (or DomQuery::create) instead of $ ๐Ÿ˜