Skip to content

Commit f4c17bb

Browse files
committed
fix: DOMParser cannot see element with id="0"
1 parent b611d38 commit f4c17bb

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

system/Test/DOMParser.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,23 +189,23 @@ protected function doXPath(?string $search, string $element, array $paths = [])
189189
$path = '';
190190

191191
// By ID
192-
if (! empty($selector['id'])) {
193-
$path = empty($selector['tag'])
192+
if (isset($selector['id'])) {
193+
$path = ($selector['tag'] === '')
194194
? "id(\"{$selector['id']}\")"
195195
: "//{$selector['tag']}[@id=\"{$selector['id']}\"]";
196196
}
197197
// By Class
198-
elseif (! empty($selector['class'])) {
199-
$path = empty($selector['tag'])
198+
elseif (isset($selector['class'])) {
199+
$path = ($selector['tag'] === '')
200200
? "//*[@class=\"{$selector['class']}\"]"
201201
: "//{$selector['tag']}[@class=\"{$selector['class']}\"]";
202202
}
203203
// By tag only
204-
elseif (! empty($selector['tag'])) {
204+
elseif ($selector['tag'] !== '') {
205205
$path = "//{$selector['tag']}";
206206
}
207207

208-
if (! empty($selector['attr'])) {
208+
if (isset($selector['attr'])) {
209209
foreach ($selector['attr'] as $key => $value) {
210210
$path .= "[@{$key}=\"{$value}\"]";
211211
}

0 commit comments

Comments
 (0)