attribute-no-space.js
2.26 KB
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
66
67
68
69
70
71
72
73
74
75
// non-strict: no error
require(__dirname).test
( { xml : '<root attr1="first"attr2="second"/>'
, expect :
[ [ "attribute", { name: 'attr1', value: 'first' } ]
, [ "attribute", { name: 'attr2', value: 'second' } ]
, [ "opentag", { name: "root", attributes: {attr1: 'first', attr2: 'second'}, isSelfClosing: true } ]
, [ "closetag", "root" ]
]
, strict : false
, opt : { lowercase: true }
}
)
// strict: should give an error, but still parse
require(__dirname).test
( { xml : '<root attr1="first"attr2="second"/>'
, expect :
[ [ "attribute", { name: 'attr1', value: 'first' } ]
, [ "error", "No whitespace between attributes\nLine: 0\nColumn: 20\nChar: a" ]
, [ "attribute", { name: 'attr2', value: 'second' } ]
, [ "opentag", { name: "root", attributes: {attr1: 'first', attr2: 'second'}, isSelfClosing: true } ]
, [ "closetag", "root" ]
]
, strict : true
, opt : { }
}
)
// strict: other cases should still pass
require(__dirname).test
( { xml : '<root attr1="first" attr2="second"/>'
, expect :
[ [ "attribute", { name: 'attr1', value: 'first' } ]
, [ "attribute", { name: 'attr2', value: 'second' } ]
, [ "opentag", { name: "root", attributes: {attr1: 'first', attr2: 'second'}, isSelfClosing: true } ]
, [ "closetag", "root" ]
]
, strict : true
, opt : { }
}
)
// strict: other cases should still pass
require(__dirname).test
( { xml : '<root attr1="first"\nattr2="second"/>'
, expect :
[ [ "attribute", { name: 'attr1', value: 'first' } ]
, [ "attribute", { name: 'attr2', value: 'second' } ]
, [ "opentag", { name: "root", attributes: {attr1: 'first', attr2: 'second'}, isSelfClosing: true } ]
, [ "closetag", "root" ]
]
, strict : true
, opt : { }
}
)
// strict: other cases should still pass
require(__dirname).test
( { xml : '<root attr1="first" attr2="second"/>'
, expect :
[ [ "attribute", { name: 'attr1', value: 'first' } ]
, [ "attribute", { name: 'attr2', value: 'second' } ]
, [ "opentag", { name: "root", attributes: {attr1: 'first', attr2: 'second'}, isSelfClosing: true } ]
, [ "closetag", "root" ]
]
, strict : true
, opt : { }
}
)