Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1b1ce8c

Browse files
committed
Add bool support.
1 parent 0eb464e commit 1b1ce8c

3 files changed

Lines changed: 10 additions & 8 deletions

File tree

lib/js2xml.coffee

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ class exports.Js2Xml
1212

1313
convert: ( structure, document, name ) ->
1414
# String
15-
if typeof structure in [ "string", "number" ]
16-
document.text structure
15+
if typeof structure in [ "string", "number", "boolean" ]
16+
document.text structure.toString()
1717

1818
# Array
1919
else if typeof structure is "object" and Array.isArray structure

lib/js2xml.js

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/js2xml_test.coffee

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ person =
1111
stuff: [ "xml", "murderers", 2, 2.3, { one: { two: "three" } } ]
1212
morestuff:
1313
milkshake: "banana"
14+
bored: true
1415

1516
assert.ok js2xml = new Js2Xml "person", person
1617
assert.ok output = js2xml.toString()
@@ -28,6 +29,7 @@ for dislike in [ "xml", "murderers", "2", "2.3" ]
2829
assert.ok doc.get "/person/stuff/item/one/two[text()='three']"
2930

3031
assert.ok doc.get "/person/morestuff/milkshake[text()='banana']"
32+
assert.ok doc.get "/person/morestuff/bored[text()='true']"
3133

3234
# check overriding pluralisation works
3335

0 commit comments

Comments
 (0)