mirror of
https://github.com/MontFerret/ferret.git
synced 2025-08-15 20:02:56 +02:00
fixes race condition when EventLoad listener isn't removed prior to the next page loading (#281)
This commit is contained in:
@@ -704,8 +704,11 @@ func (doc *HTMLDocument) WaitForClassBySelectorAll(ctx context.Context, selector
|
||||
|
||||
func (doc *HTMLDocument) WaitForNavigation(ctx context.Context) error {
|
||||
onEvent := make(chan struct{})
|
||||
var once sync.Once
|
||||
listener := func(_ context.Context, _ interface{}) {
|
||||
close(onEvent)
|
||||
once.Do(func() {
|
||||
close(onEvent)
|
||||
})
|
||||
}
|
||||
|
||||
defer doc.events.RemoveEventListener(events.EventLoad, listener)
|
||||
|
Reference in New Issue
Block a user