Skip to content

Commit

Permalink
cr fixes (will be squashed after another cr)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Stepanek committed May 22, 2019
1 parent 19a4c2f commit f074644
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
8 changes: 6 additions & 2 deletions lib/parser.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion src/parser.coffee
Expand Up @@ -145,7 +145,10 @@ class exports.Parser extends events.EventEmitter
obj = obj[charkey]

if (isEmpty obj)
obj = @options.emptyTag?() ? (if @options.emptyTag != '' then @options.emptyTag else emptyStr)
if typeof @options.emptyTag == 'function'
obj = @options.emptyTag()
else
obj = if @options.emptyTag != '' then @options.emptyTag else emptyStr

if @options.validator?
xpath = "/" + (node["#name"] for node in stack).concat(nodeName).join("/")
Expand Down
2 changes: 1 addition & 1 deletion test/parser.test.coffee
Expand Up @@ -72,7 +72,7 @@ module.exports =
# determine number of items in object
equ Object.keys(r.sample.tagcasetest[0]).length, 3)

'test parse with empty objects and functions': skeleton({emptyTag: ()=> new Object()}, (r)->
'test parse with empty objects and functions': skeleton({emptyTag: ()=> ({})}, (r)->
console.log 'Result object: ' + util.inspect r, false, 10
bool = r.sample.emptytestanother[0] is r.sample.emptytest[0]
equ bool, false)
Expand Down

0 comments on commit f074644

Please sign in to comment.