Skip to content

Commit 259b9fd

Browse files
author
Andrew Scott
committed
Fixes #36
1 parent 55df31c commit 259b9fd

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/Traits/TraversalTrait.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
*/
1717
trait TraversalTrait
1818
{
19+
protected static $cssSelectorConverter;
20+
1921
/**
2022
* @param iterable $nodes
2123
*
@@ -41,9 +43,11 @@ public function newNodeList(iterable $nodes = null): NodeList {
4143
* @return NodeList
4244
*/
4345
public function find(string $selector, string $prefix = 'descendant::'): NodeList {
44-
$converter = new CssSelectorConverter();
46+
if (!self::$cssSelectorConverter) {
47+
self::$cssSelectorConverter = new CssSelectorConverter();
48+
}
4549

46-
return $this->findXPath($converter->toXPath($selector, $prefix));
50+
return $this->findXPath(self::$cssSelectorConverter->toXPath($selector, $prefix));
4751
}
4852

4953
/**

0 commit comments

Comments
 (0)