Skip to content

Commit

Permalink
Merge branch '1.10' into 1.11
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamCampbell committed Mar 17, 2024
2 parents 50bfba6 + ee45a7b commit 7fea8a4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
* Add PHP 8.3 support


## 1.10.1 (2024-03-17)

* Fixed encoding bugs in `XPathSelector`


## 1.10.0 (2023-12-10)

* Add `Add Node::setHTML` method
Expand Down
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
The MIT License (MIT)

Copyright (c) 2017-2020 Soufiane Ghzal <[email protected]>
Copyright (c) 2020-2023 Graham Campbell <[email protected]>
Copyright (c) 2020-2023 Enrico Dias <[email protected]>
Copyright (c) 2020-2024 Graham Campbell <[email protected]>
Copyright (c) 2020-2024 Enrico Dias <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,8 @@ selectors, you can pass an instance of the required `Selector`.
Wait for element by XPath selector:

```php
use HeadlessChromium\Dom\Selector\XPathSelector;

$page = $browser->createPage();
$page->navigate('http://example.com')->waitForNavigation();

Expand Down
11 changes: 2 additions & 9 deletions src/Dom/Selector/XPathSelector.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,11 @@ public function __construct(string $expression)

public function expressionCount(): string
{
return \sprintf(
'document.evaluate("%s", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null).snapshotLength',
\addslashes($this->expression)
);
return 'document.evaluate('.\json_encode($this->expression, \JSON_THROW_ON_ERROR | \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE).', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null).snapshotLength';
}

public function expressionFindOne(int $position): string
{
return \sprintf(
'document.evaluate("%s[%d]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue',
\addslashes($this->expression),
$position
);
return 'document.evaluate('.\json_encode($this->expression."[{$position}]", \JSON_THROW_ON_ERROR | \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE).', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue';
}
}

0 comments on commit 7fea8a4

Please sign in to comment.