1
0
mirror of https://github.com/MontFerret/ferret.git synced 2025-06-17 00:07:55 +02:00

Improved events handling

This commit is contained in:
Tim Voronov
2018-09-27 11:32:52 -04:00
parent 38478e45eb
commit eeee30856e
2 changed files with 241 additions and 227 deletions

View File

@ -27,7 +27,6 @@ type HtmlDocument struct {
events *events.EventBroker
url string
element *HtmlElement
history []*HtmlElement
}
func LoadHtmlDocument(
@ -130,7 +129,6 @@ func NewHtmlDocument(
doc.client = client
doc.events = broker
doc.element = NewHtmlElement(client, broker, root.NodeID, root, innerHtml)
doc.history = make([]*HtmlElement, 0, 10)
doc.url = ""
if root.BaseURL != nil {
@ -148,8 +146,8 @@ func NewHtmlDocument(
return
}
// put the root element in a history list, since it might be still used
doc.history = append(doc.history, doc.element)
// close the prev element
doc.element.Close()
// create a new root element wrapper
doc.element = NewHtmlElement(client, broker, updated.NodeID, updated, innerHtml)
@ -228,10 +226,6 @@ func (doc *HtmlDocument) Close() error {
doc.events.Stop()
doc.events.Close()
for _, h := range doc.history {
h.Close()
}
doc.element.Close()
doc.client.Page.Close(context.Background())