1
1
package com .thoughtworks .binding
2
2
3
- import com .thoughtworks .binding .Binding .Var
3
+ import com .thoughtworks .binding .Binding .{ BindingSeq , Constants }
4
4
import com .thoughtworks .binding .dom .Runtime .TagsAndTags2
5
+ import org .scalajs .dom .Node
5
6
import org .scalatest .{FreeSpec , Matchers }
6
7
import org .scalajs .dom .html .Div
7
8
import scalatags .JsDom
@@ -12,15 +13,13 @@ import scalatags.JsDom
12
13
class ComponentModel extends FreeSpec with Matchers {
13
14
14
15
" @dom method component" in {
15
- @ dom def dialog (id : String , caption : Binding [ String ]): Binding [Div ] = <div id ={id} class =" dialog" data : dialog-caption ={caption.bind}/ >
16
+ @ dom def dialog (children : BindingSeq [ Node ]): Binding [Div ] = <div class =" dialog" >{children}</ div >
16
17
17
- val caption = Var ( " Caption " )
18
- @ dom val html = <div >{dialog(" message " , caption ).bind}</div >
18
+ @ dom val warning = Some (< div >warning</ div > )
19
+ @ dom val html = <div >{dialog(Constants (< div > Some text</ div > +: warning.bind.toSeq :_* ) ).bind}</div >
19
20
html.watch()
20
21
21
- assert(html.value.outerHTML == """ <div><div dialog-caption="Caption" class="dialog" id="message"/></div>""" )
22
- caption.value = " New caption"
23
- assert(html.value.outerHTML == """ <div><div dialog-caption="New caption" class="dialog" id="message"/></div>""" )
22
+ assert(html.value.outerHTML == """ <div><div class="dialog"><div>Some text</div><div>warning</div></div></div>""" )
24
23
}
25
24
26
25
" user defined tag component" in {
@@ -49,13 +48,11 @@ class ComponentModel extends FreeSpec with Matchers {
49
48
val dialog = Dialog
50
49
}
51
50
52
- val caption = Var ( " Caption " )
53
- @ dom val html = <div ><dialog id = " message " caption ={caption .bind}/ ></div >
51
+ @ dom val warning = Some (< div >warning</ div > )
52
+ @ dom val html = <div ><dialog >< div > Some text</ div >{warning .bind}</ dialog ></div >
54
53
html.watch()
55
54
56
- assert(html.value.outerHTML == """ <div><div class="dialog" dialog-caption="Caption" id="message"/></div>""" )
57
- caption.value = " New caption"
58
- assert(html.value.outerHTML == """ <div><div class="dialog" dialog-caption="New caption" id="message"/></div>""" )
55
+ assert(html.value.outerHTML == """ <div><div class="dialog"><div>Some text</div><div>warning</div></div></div>""" )
59
56
}
60
57
61
58
}
0 commit comments