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

Commit

Permalink
tidy up var name
Browse files Browse the repository at this point in the history
  • Loading branch information
sanity committed Jun 26, 2020
1 parent 65f5b75 commit 0fe32f9
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/main/kotlin/kweb/state/render.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@ private val logger = KotlinLogging.logger {}

fun <T : Any?> ElementCreator<*>.render(kval: KVal<T>, containerElementTag : String = "span", block: ElementCreator<Element>.(T) -> Unit) {

val containerSpan : Element = element(containerElementTag)
// NOTE: Per https://github.com/kwebio/kweb-core/issues/151 eventually render() won't rely on a container element.
val containerElement : Element = element(containerElementTag)

val previousElementCreator: AtomicReference<ElementCreator<Element>?> = AtomicReference(null)

val renderState = AtomicReference(NOT_RENDERING)

fun eraseAndRender() {
do {
containerSpan.removeChildren()
containerSpan.new {
containerElement.removeChildren()
containerElement.new {
previousElementCreator.getAndSet(this)?.cleanup()
renderState.set(RENDERING_NO_PENDING_CHANGE)
block(kval.value)
Expand All @@ -51,7 +52,7 @@ fun <T : Any?> ElementCreator<*>.render(kval: KVal<T>, containerElementTag : Str
}
}

containerSpan.new {
containerElement.new {
previousElementCreator.getAndSet(this)?.cleanup()
renderState.set(RENDERING_NO_PENDING_CHANGE)
block(kval.value)
Expand All @@ -64,7 +65,7 @@ fun <T : Any?> ElementCreator<*>.render(kval: KVal<T>, containerElementTag : Str
}

this.onCleanup(false) {
containerSpan.deleteIfExists()
containerElement.deleteIfExists()
}

this.onCleanup(true) {
Expand Down

0 comments on commit 0fe32f9

Please sign in to comment.