From 5a396d12da3b063a8f0af5a648861d9b4b7a41e5 Mon Sep 17 00:00:00 2001 From: Ian Clarke Date: Sun, 28 May 2023 10:49:09 -0500 Subject: [PATCH] revert recent changes that seem to be causing very weird css issues, then remove .trimIndent() again --- src/main/kotlin/kweb/Element.kt | 22 +++++++++---------- src/main/kotlin/kweb/ElementCreator.kt | 4 ++-- src/main/kotlin/kweb/Kweb.kt | 2 +- src/main/kotlin/kweb/ValueElement.kt | 2 +- src/main/kotlin/kweb/WebBrowser.kt | 2 +- src/main/kotlin/kweb/html/Document.kt | 2 +- src/main/kotlin/kweb/html/Window.kt | 4 ++-- .../kweb/html/fileUpload/FileFormInput.kt | 2 +- .../plugins/fomanticUI/FomanticUIClasses.kt | 2 +- .../plugins/specificKeyUp/SpecificKeyUp.kt | 2 +- src/main/kotlin/kweb/state/renderEach.kt | 4 ++-- src/test/kotlin/kweb/demos/todo/TodoApp.kt | 2 +- 12 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/main/kotlin/kweb/Element.kt b/src/main/kotlin/kweb/Element.kt index eae52858c5..568eeff805 100644 --- a/src/main/kotlin/kweb/Element.kt +++ b/src/main/kotlin/kweb/Element.kt @@ -269,7 +269,7 @@ open class Element( let el = document.getElementById(id); if (el.classList) el.classList.add(className); else if (!hasClass(el, className)) el.className += " " + className; - """.trimIndent(), id.json, JsonPrimitive(class_) + """, id.json, JsonPrimitive(class_) ) } } @@ -302,7 +302,7 @@ open class Element( var reg = new RegExp("(\\s|^)" + className + "(\\s|${'$'})"); el.className = el.className.replace(reg, " "); } - """.trimIndent(), id.json, JsonPrimitive(class_) + """, id.json, JsonPrimitive(class_) ) } } @@ -348,7 +348,7 @@ open class Element( element.removeChild(element.firstChild); } } - """.trimIndent(), id.json + """, id.json ) } } @@ -383,7 +383,7 @@ open class Element( startSpan.parentNode.removeChild(startSpan.nextSibling); nextSibling = startSpan.nextSibling; } - """.trimIndent(), JsonPrimitive(startSpanId), JsonPrimitive(endSpanId) + """, JsonPrimitive(startSpanId), JsonPrimitive(endSpanId) ) } } @@ -405,7 +405,7 @@ open class Element( """ let element = document.getElementById({}); element.removeChild(element.children[{}]); - """.trimIndent(), id.json, position.json + """, id.json, position.json ) } } @@ -419,7 +419,7 @@ open class Element( fun text(value: String): Element { val jsoupDoc = browser.htmlDocument.get() //language=JavaScript - val setTextJS = """document.getElementById({}).textContent = {};""".trimIndent() + val setTextJS = """document.getElementById({}).textContent = {};""" when { jsoupDoc != null && (browser.isCatchingOutbound() == null || browser.isCatchingOutbound() == RENDER) -> { val element = jsoupDoc.getElementById(this.id) @@ -464,7 +464,7 @@ open class Element( val createTextNodeJs = """ var ntn = document.createTextNode({}); document.getElementById({}).appendChild(ntn); - """.trimIndent() + """ when { jsoupDoc != null && (browser.isCatchingOutbound() == null || browser.isCatchingOutbound() == RENDER) -> { val element = jsoupDoc.getElementById(this.id) @@ -483,7 +483,7 @@ open class Element( val wrappedJS = """ return document.getElementById({}).addEventListener({}, function(event) { $jsCode - });""".trimIndent() + });""" browser.callJsFunction(wrappedJS, id.json, JsonPrimitive(eventName)) } @@ -510,7 +510,7 @@ open class Element( callbackWs({}, $eventObject); }); return true; - """.trimIndent() + """ //Adding event listener was causing the client to send a Client2ServerMessage with a null data field. This caused an error //We make the client return true to avoid that issue. //Then on the server we only invoke our callback on eventObjects, by checking that payload is a JsonObject. @@ -589,7 +589,7 @@ open class Element( """ let element = document.getElementById({}); element.parentNode.removeChild(element); - """.trimIndent(), id.json + """, id.json ) } @@ -607,7 +607,7 @@ open class Element( let element = document.getElementById(id); element.parentNode.removeChild(element); } - """.trimIndent(), id.json + """, id.json ) } catch (e: IllegalStateException) { diff --git a/src/main/kotlin/kweb/ElementCreator.kt b/src/main/kotlin/kweb/ElementCreator.kt index 3677b37576..48456dc5b1 100755 --- a/src/main/kotlin/kweb/ElementCreator.kt +++ b/src/main/kotlin/kweb/ElementCreator.kt @@ -116,7 +116,7 @@ open class ElementCreator( } else { parentElement.appendChild(newEl); } - """.trimIndent() + """ browser.callJsFunction( createElementJs, JsonPrimitive(tag), JsonObject(mutAttributes), id.json, JsonPrimitive(element.id), JsonPrimitive(insertBefore ?: ""), JsonPrimitive(elementsCreatedCount) @@ -148,7 +148,7 @@ open class ElementCreator( } else { parentElement.appendChild(newEl); } - """.trimIndent() + """ element.browser.callJsFunction( createElementJs, tag.json, JsonObject(mutAttributes), id.json, element.id.json, JsonPrimitive(insertBefore ?: ""), JsonPrimitive(elementsCreatedCount) diff --git a/src/main/kotlin/kweb/Kweb.kt b/src/main/kotlin/kweb/Kweb.kt index 435e6d6032..b373233f3c 100755 --- a/src/main/kotlin/kweb/Kweb.kt +++ b/src/main/kotlin/kweb/Kweb.kt @@ -464,7 +464,7 @@ class Kweb private constructor( Internal Server Error. Please include code $logToken in any error report to help us track it down. -""".trimIndent() +""" ) } } diff --git a/src/main/kotlin/kweb/ValueElement.kt b/src/main/kotlin/kweb/ValueElement.kt index 9d05c6d75e..e98537db99 100644 --- a/src/main/kotlin/kweb/ValueElement.kt +++ b/src/main/kotlin/kweb/ValueElement.kt @@ -39,7 +39,7 @@ abstract class ValueElement( const element = document.getElementById({}); element.value = {}; delete element.dataset.previousInput; - """.trimIndent(), + """, element.id.json, newValue.json ) } diff --git a/src/main/kotlin/kweb/WebBrowser.kt b/src/main/kotlin/kweb/WebBrowser.kt index d8daf07e59..315ac74bfa 100755 --- a/src/main/kotlin/kweb/WebBrowser.kt +++ b/src/main/kotlin/kweb/WebBrowser.kt @@ -365,7 +365,7 @@ class WebBrowser(val sessionId: String, val httpRequestInfo: HttpRequestInfo, va //language=JavaScript callJsFunction(""" history.pushState({ }, "", {}); - """.trimIndent(), JsonPrimitive(url)) + """, JsonPrimitive(url)) } /** diff --git a/src/main/kotlin/kweb/html/Document.kt b/src/main/kotlin/kweb/html/Document.kt index f6ee7b1203..7147f24293 100755 --- a/src/main/kotlin/kweb/html/Document.kt +++ b/src/main/kotlin/kweb/html/Document.kt @@ -82,7 +82,7 @@ class Document(val receiver: WebBrowser) : EventGenerator { return document.addEventListener({}, function(event) { $jsCode }); - """.trimIndent() + """ documentScope.launch { receiver.callJsFunctionWithResult(wrappedJS, JsonPrimitive(eventName)) } diff --git a/src/main/kotlin/kweb/html/Window.kt b/src/main/kotlin/kweb/html/Window.kt index dc48f40cb6..04d972a52c 100644 --- a/src/main/kotlin/kweb/html/Window.kt +++ b/src/main/kotlin/kweb/html/Window.kt @@ -24,7 +24,7 @@ class Window(override val browser: WebBrowser) : EventGenerator { return window.addEventListener({}, function(event) { $jsCode }); - """.trimIndent() + """ browser.callJsFunction(wrappedJS, eventName.json) } @@ -38,7 +38,7 @@ class Window(override val browser: WebBrowser) : EventGenerator { callbackWs({}, $eventObject); }); return true; - """.trimIndent() + """ browser.callJsFunctionWithCallback(js, callbackId, callback = { payload -> if (payload is JsonObject) { callback.invoke(payload) diff --git a/src/main/kotlin/kweb/html/fileUpload/FileFormInput.kt b/src/main/kotlin/kweb/html/fileUpload/FileFormInput.kt index 7176573beb..cdccdf244b 100644 --- a/src/main/kotlin/kweb/html/fileUpload/FileFormInput.kt +++ b/src/main/kotlin/kweb/html/fileUpload/FileFormInput.kt @@ -52,7 +52,7 @@ class FileFormInput { fr.onload = function(){ callbackWs({}, {base64Content: fr.result, fileSize: fd.size, fileName: fd.name}); } - """.trimIndent() + """ inputElement.browser.callJsFunctionWithCallback(js, callbackId, callback = { result -> logger.info("Result is $result") diff --git a/src/main/kotlin/kweb/plugins/fomanticUI/FomanticUIClasses.kt b/src/main/kotlin/kweb/plugins/fomanticUI/FomanticUIClasses.kt index 9c399b894a..60b0e8b4e2 100755 --- a/src/main/kotlin/kweb/plugins/fomanticUI/FomanticUIClasses.kt +++ b/src/main/kotlin/kweb/plugins/fomanticUI/FomanticUIClasses.kt @@ -1203,7 +1203,7 @@ class FomanticUIClasses : AttributeBuilder() { error(""" The .ui getter has already been used on this SematicUIClasses object. Please ensure you are creating a fresh FomanticUIClasses object (using the 'fomantic' getter for every element). -""".trimIndent()) +""") } classes("ui") uiClassAlreadyPresent = true diff --git a/src/main/kotlin/kweb/plugins/specificKeyUp/SpecificKeyUp.kt b/src/main/kotlin/kweb/plugins/specificKeyUp/SpecificKeyUp.kt index c8d6c737a8..3f0d20b28f 100644 --- a/src/main/kotlin/kweb/plugins/specificKeyUp/SpecificKeyUp.kt +++ b/src/main/kotlin/kweb/plugins/specificKeyUp/SpecificKeyUp.kt @@ -40,7 +40,7 @@ fun InputElement.attachKeySpecificKeyupEvent(vararg keys: String) { element.dispatchEvent(keySpecificKeyUpEvent); } }); -""".trimIndent(), id.json, JsonPrimitive(keys.joinToString(separator = ",")) +""", id.json, JsonPrimitive(keys.joinToString(separator = ",")) ) } diff --git a/src/main/kotlin/kweb/state/renderEach.kt b/src/main/kotlin/kweb/state/renderEach.kt index f7989c58d8..4328f6442c 100644 --- a/src/main/kotlin/kweb/state/renderEach.kt +++ b/src/main/kotlin/kweb/state/renderEach.kt @@ -54,7 +54,7 @@ fun ElementCreator.renderEach( } parent.removeChild(start_element); parent.removeChild(end_element); - """.trimIndent(), JsonPrimitive(renderHandleToRemove.startId), + """, JsonPrimitive(renderHandleToRemove.startId), JsonPrimitive(renderHandleToRemove.endId) ) renderHandleToRemove.delete() @@ -80,7 +80,7 @@ fun ElementCreator.renderEach( elementsToMove.forEach(function (item){ listParent.insertBefore(item, endMarker); }); - """.trimIndent() + """ browser.callJsFunction(moveItemCode, JsonPrimitive(itemStartMarker), JsonPrimitive(itemEndMarker), JsonPrimitive(newPosMarker) ) diff --git a/src/test/kotlin/kweb/demos/todo/TodoApp.kt b/src/test/kotlin/kweb/demos/todo/TodoApp.kt index b99e35e9ff..2ed74bc626 100755 --- a/src/test/kotlin/kweb/demos/todo/TodoApp.kt +++ b/src/test/kotlin/kweb/demos/todo/TodoApp.kt @@ -99,7 +99,7 @@ class TodoApp { You may find the source code for this app here. """ - .trimIndent() + ) } }