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

Commit

Permalink
slightly improve commenting
Browse files Browse the repository at this point in the history
  • Loading branch information
sanity committed Jul 19, 2018
1 parent 41c70cc commit f9c1cd2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main/kotlin/io/kweb/state/persistent/persistent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ fun main(args: Array<String>) {
fun <T : Any> ElementCreator<*>.render(kval : KVal<T>, cacheOnClient : Boolean = false, renderer : ElementCreator<Element>.(T) -> Unit) {
var childEC = ElementCreator(this.parent, this)
val cachedClientECs = if (cacheOnClient) ConcurrentHashMap<T, ElementCreator<Element>>() else null

// Before we set them to display:none, we retrieve the values of the "style" attribute so that we can
// put it back again correctly, because we're thoughtful like that.
val retrievedStyleValues = ConcurrentHashMap<T, String>()
val kvalListenerHandle = kval.addListener { oldValue, newValue ->
if (oldValue != newValue) {
Expand All @@ -62,9 +65,6 @@ fun <T : Any> ElementCreator<*>.render(kval : KVal<T>, cacheOnClient : Boolean =
if (retainedEC == null) {
renderer(childEC, newValue)
} else {
// FIXME: Do we need to cache the values of style.display here? I'm assuming
// block, but it could be 'inline' - which would cause some weird
// and tough to track down bugs.
retainedEC.elementsCreated.forEach {
val prevStyle = retrievedStyleValues[newValue]
if (prevStyle == null) {
Expand Down

0 comments on commit f9c1cd2

Please sign in to comment.