Skip to content

Commit df87aa4

Browse files
committed
removeCss, improved code
1 parent a4890e4 commit df87aa4

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
99
### Added
1010
- Ability to send settings to `CurlClient`. Added the `cookies_path` setting to customize the file used for cookies. #345
1111
- `Document::selectCss()` function to select elements using css selectors instead xpath (it requires symfony/css-selector)
12+
- `Document::removeCss()` function to remove elements using css selectors instead xpath (it requires symfony/css-selector)
1213

1314
## 4.0.0 - 2020-03-13
1415
Full library refactoring.

src/Document.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ public function remove(string $query): void
5050
}
5151
}
5252

53+
public function removeCss(string $query): void
54+
{
55+
$this->remove(self::cssToXpath($query));
56+
}
57+
5358
public function getDocument(): DOMDocument
5459
{
5560
return $this->document;
@@ -86,9 +91,7 @@ public function select(string $query, array $attributes = null, DOMNode $context
8691
*/
8792
public function selectCss(string $query, DOMNode $context = null): QueryResult
8893
{
89-
$query = self::cssToXpath($query);
90-
91-
return new QueryResult($this->xpath->query($query, $context), $this->extractor);
94+
return $this->select(self::cssToXpath($query), null, $context);
9295
}
9396

9497
/**

0 commit comments

Comments
 (0)