tenderowls / moorka

ABANDONED
21 stars 5 forks source link

"switch" block should insert new element to the previous position #53

Closed vsuharnikov closed 9 years ago

vsuharnikov commented 9 years ago

How to reproduce the problem:

val rx: Var[Boolean] = true

div(
  cls := "outer",
  switch(
    rx map {
      if (_) span(cls := "inner-1-true")
      else span(cls := "inner-1-false")
    }
  ),
  span(cls := "inner-2")
)

/* 
<div class="outer">
  <span class="inner-1-true"></span>
  <span class="inner-2"></span>
</div>
 */

// Later
rx.pull(false)

/* 
<div class="outer">
  <span class="inner-2"></span>
  <span class="inner-1-false"></span>
</div>
 */

Adding an outer element (for switch block) leads to adding unnecessary CSS-classes and styles.

We should add an empty element (in a position of the switch), and then replace it when the state changes.