Previously, a new Dom instance was created for each call of $page->dom(). In this pull request, I have stored $dom as a variable in the Page class and added an auto-update of the root node id using the DOM.documentUpdated event.
I use waitForData() from upcoming chrome-php/wrench 1.7 to process all events before each request without blocking execution if there is no data to process. When the page is refreshed in Chrome, chrome-php will be notified about it before making any requests. Somehow, Chrome fires two DOM.documentUpdated events during one reload, so I decided to not fetch the node ID in the event handler but just mark the node as stale and request a new node ID before making a request if the old one is stale.
It is a fix for issue 469
Previously, a new
Dom
instance was created for each call of$page->dom()
. In this pull request, I have stored$dom
as a variable in thePage
class and added an auto-update of the root node id using theDOM.documentUpdated
event.I use
waitForData()
from upcomingchrome-php/wrench
1.7 to process all events before each request without blocking execution if there is no data to process. When the page is refreshed in Chrome, chrome-php will be notified about it before making any requests. Somehow, Chrome fires twoDOM.documentUpdated
events during one reload, so I decided to not fetch the node ID in the event handler but just mark the node as stale and request a new node ID before making a request if the old one is stale.