Skip to content
This repository has been archived by the owner on Aug 10, 2024. It is now read-only.

Commit

Permalink
revert recent changes that seem to be causing very weird css issues, …
Browse files Browse the repository at this point in the history
…then remove .trimIndent() again
  • Loading branch information
sanity committed May 28, 2023
1 parent 76baa93 commit 5a396d1
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 25 deletions.
22 changes: 11 additions & 11 deletions src/main/kotlin/kweb/Element.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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_)
)
}
}
Expand Down Expand Up @@ -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_)
)
}
}
Expand Down Expand Up @@ -348,7 +348,7 @@ open class Element(
element.removeChild(element.firstChild);
}
}
""".trimIndent(), id.json
""", id.json
)
}
}
Expand Down Expand Up @@ -383,7 +383,7 @@ open class Element(
startSpan.parentNode.removeChild(startSpan.nextSibling);
nextSibling = startSpan.nextSibling;
}
""".trimIndent(), JsonPrimitive(startSpanId), JsonPrimitive(endSpanId)
""", JsonPrimitive(startSpanId), JsonPrimitive(endSpanId)
)
}
}
Expand All @@ -405,7 +405,7 @@ open class Element(
"""
let element = document.getElementById({});
element.removeChild(element.children[{}]);
""".trimIndent(), id.json, position.json
""", id.json, position.json
)
}
}
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -483,7 +483,7 @@ open class Element(
val wrappedJS = """
return document.getElementById({}).addEventListener({}, function(event) {
$jsCode
});""".trimIndent()
});"""
browser.callJsFunction(wrappedJS, id.json, JsonPrimitive(eventName))
}

Expand All @@ -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.
Expand Down Expand Up @@ -589,7 +589,7 @@ open class Element(
"""
let element = document.getElementById({});
element.parentNode.removeChild(element);
""".trimIndent(), id.json
""", id.json
)
}

Expand All @@ -607,7 +607,7 @@ open class Element(
let element = document.getElementById(id);
element.parentNode.removeChild(element);
}
""".trimIndent(), id.json
""", id.json
)
} catch (e: IllegalStateException) {

Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/kweb/ElementCreator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ open class ElementCreator<out PARENT_TYPE : Element>(
} else {
parentElement.appendChild(newEl);
}
""".trimIndent()
"""
browser.callJsFunction(
createElementJs, JsonPrimitive(tag), JsonObject(mutAttributes), id.json,
JsonPrimitive(element.id), JsonPrimitive(insertBefore ?: ""), JsonPrimitive(elementsCreatedCount)
Expand Down Expand Up @@ -148,7 +148,7 @@ open class ElementCreator<out PARENT_TYPE : Element>(
} else {
parentElement.appendChild(newEl);
}
""".trimIndent()
"""
element.browser.callJsFunction(
createElementJs, tag.json, JsonObject(mutAttributes), id.json,
element.id.json, JsonPrimitive(insertBefore ?: ""), JsonPrimitive(elementsCreatedCount)
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/kweb/Kweb.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
"""
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/kweb/ValueElement.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ abstract class ValueElement(
const element = document.getElementById({});
element.value = {};
delete element.dataset.previousInput;
""".trimIndent(),
""",
element.id.json, newValue.json
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/kweb/WebBrowser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ class WebBrowser(val sessionId: String, val httpRequestInfo: HttpRequestInfo, va
//language=JavaScript
callJsFunction("""
history.pushState({ }, "", {});
""".trimIndent(), JsonPrimitive(url))
""", JsonPrimitive(url))
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/kweb/html/Document.kt
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class Document(val receiver: WebBrowser) : EventGenerator<Document> {
return document.addEventListener({}, function(event) {
$jsCode
});
""".trimIndent()
"""
documentScope.launch {
receiver.callJsFunctionWithResult(wrappedJS, JsonPrimitive(eventName))
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/kweb/html/Window.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Window(override val browser: WebBrowser) : EventGenerator<Window> {
return window.addEventListener({}, function(event) {
$jsCode
});
""".trimIndent()
"""
browser.callJsFunction(wrappedJS, eventName.json)
}

Expand All @@ -38,7 +38,7 @@ class Window(override val browser: WebBrowser) : EventGenerator<Window> {
callbackWs({}, $eventObject);
});
return true;
""".trimIndent()
"""
browser.callJsFunctionWithCallback(js, callbackId, callback = { payload ->
if (payload is JsonObject) {
callback.invoke(payload)
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/kweb/html/fileUpload/FileFormInput.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ","))
)
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/kweb/state/renderEach.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fun <ITEM : Any, EL : Element> ElementCreator<EL>.renderEach(
}
parent.removeChild(start_element);
parent.removeChild(end_element);
""".trimIndent(), JsonPrimitive(renderHandleToRemove.startId),
""", JsonPrimitive(renderHandleToRemove.startId),
JsonPrimitive(renderHandleToRemove.endId)
)
renderHandleToRemove.delete()
Expand All @@ -80,7 +80,7 @@ fun <ITEM : Any, EL : Element> ElementCreator<EL>.renderEach(
elementsToMove.forEach(function (item){
listParent.insertBefore(item, endMarker);
});
""".trimIndent()
"""
browser.callJsFunction(moveItemCode, JsonPrimitive(itemStartMarker),
JsonPrimitive(itemEndMarker), JsonPrimitive(newPosMarker)
)
Expand Down
2 changes: 1 addition & 1 deletion src/test/kotlin/kweb/demos/todo/TodoApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class TodoApp {
You may find the source code for this app
<a href="https://github.com/kwebio/kweb-core/tree/master/src/main/kotlin/kweb/demos/todo">here</a>.
"""
.trimIndent()

)
}
}
Expand Down

0 comments on commit 5a396d1

Please sign in to comment.