Skip to content

Commit 85903fa

Browse files
committed
feat: rules add attrs
1 parent e527c63 commit 85903fa

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Dom/Query.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,13 @@ protected function extractContent(phpQueryObject $pqObj, $ruleName, $rule)
209209
})->all();
210210
break;
211211
default:
212-
$content = $pqObj->attr($rule['attr']);
212+
if(preg_match('/attr\((.+)\)/', $rule['attr'], $arr)) {
213+
$content = $pqObj->attr($arr[1]);
214+
} elseif (preg_match('/attrs\((.+)\)/', $rule['attr'], $arr)) {
215+
$content = (new Elements($pqObj))->attrs($arr[1])->all();
216+
} else {
217+
$content = $pqObj->attr($rule['attr']);
218+
}
213219
break;
214220
}
215221

0 commit comments

Comments
 (0)