Skip to content

Commit

Permalink
Painless HTML creation
Browse files Browse the repository at this point in the history
  • Loading branch information
glmars committed Oct 31, 2018
1 parent 3b84538 commit 29f2322
Showing 1 changed file with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions dom/src/test/scala/com/thoughtworks/binding/ComponentModel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.thoughtworks.binding.Binding.Var
import com.thoughtworks.binding.dom.Runtime.TagsAndTags2
import org.scalatest.{FreeSpec, Matchers}
import org.scalajs.dom.html.Div
import scalatags.JsDom

/**
* @author Leonid Turnaev <[email protected]>
Expand All @@ -24,25 +23,9 @@ class ComponentModel extends FreeSpec with Matchers {
}

"user defined tag component" in {
import scala.language.implicitConversions

class Dialog(val div: Div) {
def caption: String = {
div.getAttribute("dialog-caption")
}
def caption_=(caption: String): Unit = {
div.setAttribute("dialog-caption", caption)
}
}

object Dialog {
implicit final def toDiv(tag: Dialog): Div = tag.div

def render: Dialog = {
val div = JsDom.tags.div.render
div.className = "dialog"
new Dialog(div)
}
@dom
def apply(id: String, caption: Binding[String]): Binding[Div] = <div id={id} class="dialog" data:dialog-caption={caption.bind}/>
}

implicit final class UserTags(x: TagsAndTags2.type) {
Expand Down

0 comments on commit 29f2322

Please sign in to comment.