Skip to content

Commit

Permalink
Merge branch 'master' of github.com:jae-jae/QueryList into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
jae-jae committed Mar 15, 2020
2 parents 02c2b12 + 25b2dbd commit 52bbdea
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion src/Dom/Elements.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,34 @@ public function __call($name, $arguments)
return $obj;
}

/**
* Iterating elements
*
* @param callable $callback
*
* @return $this
*/
public function each(callable $callback)
{
$break = false;
$this->elements->each(function ($dom) use ($callback, &$break) {
if ( ! $dom || $break) {
return;
}
$orig = $dom;
$dom = new Elements(pq($dom));
if (false === call_user_func($callback, $dom)) {
$dom = $orig;
$break = true;
} else {
$dom = $dom->getDOMDocument();
}
unset($orig);
});

return $this;
}

/**
* Iterating elements
*
Expand All @@ -184,7 +212,7 @@ public function map($callback)
/**
* Gets the attributes of all the elements
*
* @param $attr HTML attribute name
* @param string $attr HTML attribute name
* @return \Illuminate\Support\Collection|\Tightenco\Collect\Support\Collection
*/
public function attrs($attr)
Expand Down

0 comments on commit 52bbdea

Please sign in to comment.