Skip to content

Commit b398ec5

Browse files
committed
Do not coerce element name
1 parent 2986b0a commit b398ec5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/XMLNode.coffee

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ module.exports = class XMLNode
6161
lastChild = @element key, val
6262

6363
else
64-
name = '' + name
65-
6664
# text node
6765
if @stringify.convertTextKey and name.indexOf(@stringify.convertTextKey) == 0
6866
lastChild = @text text
@@ -147,6 +145,11 @@ module.exports = class XMLNode
147145
# `attributes` an object containing name/value pairs of attributes
148146
# `text` element text
149147
node: (name, attributes, text) ->
148+
attributes ?= {}
149+
# swap argument order: text <-> attributes
150+
if not _.isObject attributes
151+
[text, attributes] = [attributes, text]
152+
150153
XMLElement = require './XMLElement'
151154
child = new XMLElement @, name, attributes
152155
child.text(text) if text?

0 commit comments

Comments
 (0)