Skip to content

Commit 29f2322

Browse files
committed
Painless HTML creation
1 parent 3b84538 commit 29f2322

File tree

1 file changed

+2
-19
lines changed

1 file changed

+2
-19
lines changed

dom/src/test/scala/com/thoughtworks/binding/ComponentModel.scala

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import com.thoughtworks.binding.Binding.Var
44
import com.thoughtworks.binding.dom.Runtime.TagsAndTags2
55
import org.scalatest.{FreeSpec, Matchers}
66
import org.scalajs.dom.html.Div
7-
import scalatags.JsDom
87

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

2625
"user defined tag component" in {
27-
import scala.language.implicitConversions
28-
29-
class Dialog(val div: Div) {
30-
def caption: String = {
31-
div.getAttribute("dialog-caption")
32-
}
33-
def caption_=(caption: String): Unit = {
34-
div.setAttribute("dialog-caption", caption)
35-
}
36-
}
37-
3826
object Dialog {
39-
implicit final def toDiv(tag: Dialog): Div = tag.div
40-
41-
def render: Dialog = {
42-
val div = JsDom.tags.div.render
43-
div.className = "dialog"
44-
new Dialog(div)
45-
}
27+
@dom
28+
def apply(id: String, caption: Binding[String]): Binding[Div] = <div id={id} class="dialog" data:dialog-caption={caption.bind}/>
4629
}
4730

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

0 commit comments

Comments
 (0)