1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
suite 'Attributes:', ->
result = ''
data = (chunk, level) ->
result += chunk
test 'All forms of att() usage', ->
result = ''
doc(data)
.node('test4')
.ele('node', {"first":"1", "second":"2"})
.att("third", "3")
.up()
.ele('node').att({"first":"1", "second":"2"}).up()
.up()
.end()
eq(
result
'<test4>' +
'<node first="1" second="2" third="3"/>' +
'<node first="1" second="2"/>' +
'</test4>'
)
test 'Skip null attributes', ->
result = ''
doc(data)
.node('test')
.ele('node', {"first": null})
.att("third", null)
.up()
.ele('node').att({"first": null}).up()
.up()
.end()
eq(
result
'<test>' +
'<node/>' +
'<node/>' +
'</test>'
)
test 'Keep null attributes', ->
result = ''
doc({ keepNullAttributes: true }, data)
.node('test')
.ele('node', {"first": null})
.att("second", null)
.up()
.ele('node').att({"first": null}).up()
.up()
.end()
eq(
result
'<test>' +
'<node first="" second=""/>' +
'<node first=""/>' +
'</test>'
)
|