From 162f6dab3360a90a527063c3a18e7203e1e4b058 Mon Sep 17 00:00:00 2001 From: Alexei Anoshenko <2277098+anoshenko@users.noreply.github.com> Date: Sun, 30 Aug 2026 12:43:58 +0300 Subject: [PATCH] Bug fixing --- app_scripts.js | 8 ++++++++ popup.go | 2 +- session.go | 12 ------------ stackLayout.go | 6 +++--- viewsContainer.go | 2 +- wasmBridge.go | 13 ------------- webBridge.go | 4 ---- 7 files changed, 13 insertions(+), 34 deletions(-) diff --git a/app_scripts.js b/app_scripts.js index 2e1d6e6..c6d6eb1 100644 --- a/app_scripts.js +++ b/app_scripts.js @@ -211,6 +211,14 @@ function appendToInnerHTML(elementId, content) { } } +function appendElement(elementId, content) { + const element = document.getElementById(elementId); + if (element) { + element.insertAdjacentHTML("beforeend", content); + scanElementsSize(); + } +} + function appendToInputValue(elementId, content) { const element = document.getElementById(elementId); if (element) { diff --git a/popup.go b/popup.go index a99b0cd..eb6289f 100644 --- a/popup.go +++ b/popup.go @@ -1704,7 +1704,7 @@ func (manager *popupManager) showPopup(popup Popup) { session := popup.Session() session.callFunc("blurCurrent") - session.appendToInnerHTML(popupLayerID, popup.html(false)) + session.callFunc("appendElement", popupLayerID, popup.html(false)) session.updateCSSProperty("ruiTooltipLayer", "visibility", "hidden") session.updateCSSProperty("ruiTooltipLayer", "opacity", "0") diff --git a/session.go b/session.go index 5936ef8..021b469 100644 --- a/session.go +++ b/session.go @@ -17,7 +17,6 @@ type bridge interface { callFunc(funcName string, args ...any) bool localStorageRequest(funcName string, args ...any) updateInnerHTML(htmlID, html string) - appendToInnerHTML(htmlID, html string) updateCSSProperty(htmlID, property, value string) updateProperty(htmlID, property string, value any) removeProperty(htmlID, property string) @@ -172,7 +171,6 @@ type Session interface { writeInitScript() callFunc(funcName string, args ...any) updateInnerHTML(htmlID, html string) - appendToInnerHTML(htmlID, html string) updateCSSProperty(htmlID, property, value string) updateProperty(htmlID, property string, value any) removeProperty(htmlID, property string) @@ -489,16 +487,6 @@ func (session *sessionData) updateInnerHTML(htmlID, html string) { } } -func (session *sessionData) appendToInnerHTML(htmlID, html string) { - if !session.ignoreViewUpdates() { - if session.bridge != nil { - session.bridge.appendToInnerHTML(htmlID, html) - } else { - ErrorLog("No connection") - } - } -} - func (session *sessionData) updateCSSProperty(htmlID, property, value string) { if !session.ignoreViewUpdates() { if session.bridge != nil { diff --git a/stackLayout.go b/stackLayout.go index 9b9526a..f811dda 100644 --- a/stackLayout.go +++ b/stackLayout.go @@ -677,7 +677,7 @@ func (layout *stackLayoutData) Append(view View) { if count > 0 { session.updateCSSProperty(layout.views[count-1].htmlID()+"page", "visibility", "hidden") } - session.appendToInnerHTML(stackID, buffer.String()) + session.callFunc("appendElement", stackID, buffer.String()) layout.runChangeListener(Content) } @@ -713,7 +713,7 @@ func (layout *stackLayoutData) Insert(view View, index int) { buffer.WriteString(``) session := layout.Session() - session.appendToInnerHTML(stackID, buffer.String()) + session.callFunc("appendElement", stackID, buffer.String()) layout.runChangeListener(Content) } @@ -805,7 +805,7 @@ func (layout *stackLayoutData) Push(view View, onPushFinished ...func()) { viewHTML(view, buffer, "") buffer.WriteString(``) - session.appendToInnerHTML(layout.htmlID(), buffer.String()) + session.callFunc("appendElement", layout.htmlID(), buffer.String()) if prevPeek != "" { mirror := transformMirror(transform, session) diff --git a/viewsContainer.go b/viewsContainer.go index f88f6de..b9139d7 100644 --- a/viewsContainer.go +++ b/viewsContainer.go @@ -111,7 +111,7 @@ func (container *viewsContainerData) Append(view View) { defer freeStringBuilder(buffer) viewHTML(view, buffer, "") - container.Session().appendToInnerHTML(container.htmlID(), buffer.String()) + container.Session().callFunc("appendElement", container.htmlID(), buffer.String()) container.runChangeListener(Content) } } diff --git a/wasmBridge.go b/wasmBridge.go index 4b39a1c..80e40ee 100644 --- a/wasmBridge.go +++ b/wasmBridge.go @@ -79,19 +79,6 @@ func (bridge *wasmBridge) updateInnerHTML(htmlID, html string) { } } -func (bridge *wasmBridge) appendToInnerHTML(htmlID, html string) { - if ProtocolInDebugLog { - DebugLog(fmt.Sprintf("%s.innerHTML += '%s'", htmlID, html)) - } - - element := js.Global().Get("document").Call("getElementById", htmlID) - if !element.IsUndefined() && !element.IsNull() { - oldHtml := element.Get("innerHTML").String() - element.Set("innerHTML", oldHtml+html) - js.Global().Call("scanElementsSize") - } -} - func (bridge *wasmBridge) updateCSSProperty(htmlID, property, value string) { if ProtocolInDebugLog { DebugLog(fmt.Sprintf("%s.style[%s] = '%s'", htmlID, property, value)) diff --git a/webBridge.go b/webBridge.go index 156663b..157db91 100644 --- a/webBridge.go +++ b/webBridge.go @@ -265,10 +265,6 @@ func (bridge *webBridge) updateInnerHTML(htmlID, html string) { bridge.callFunc("updateInnerHTML", htmlID, html) } -func (bridge *webBridge) appendToInnerHTML(htmlID, html string) { - bridge.callFunc("appendToInnerHTML", htmlID, html) -} - func (bridge *webBridge) updateCSSProperty(htmlID, property, value string) { if buffer, ok := bridge.updateScripts[htmlID]; ok { buffer.WriteString(`element.style['`)