* [misc] fix zin hook query()->first/last() not work.

This commit is contained in:
sunhao
2025-03-27 16:15:45 +08:00
committed by 刘刚
parent 2ef2a3ce48
commit 40db9c6ada
2 changed files with 6 additions and 4 deletions
+4 -2
View File
@@ -173,8 +173,9 @@ class command
return $list;
}
public static function first(array $nodes, string|array|object $selectors)
public static function first(array $nodes, string|array|object|null $selectors = null)
{
if($selectors === null) return reset($nodes);
foreach($nodes as $node)
{
$result = $node->findFirst($selectors);
@@ -183,8 +184,9 @@ class command
return array();
}
public static function last(array $nodes, string|array|object $selectors)
public static function last(array $nodes, string|array|object|null $selectors = null)
{
if($selectors === null) return end($nodes);
foreach($nodes as $node)
{
$result = $node->findLast($selectors);