Skip to content

Commit

Permalink
fix(client): does not throws an error for non DOM object that has `ta…
Browse files Browse the repository at this point in the history
…gName` property

fixes #2139
  • Loading branch information
maksimr committed May 28, 2016
1 parent 13368e6 commit ba55afb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion client/stringify.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
var serialize = require('dom-serialize')
var instanceOf = require('./util').instanceOf
var isNode = function (obj) {
return (obj.tagName || obj.nodeName) && obj.nodeType
}

var stringify = function stringify (obj, depth) {
if (depth === 0) {
Expand Down Expand Up @@ -38,7 +41,7 @@ var stringify = function stringify (obj, depth) {
return '<!--' + obj.nodeValue + '-->'
} else if (obj.outerHTML) {
return obj.outerHTML
} else if (obj.tagName || obj.nodeName) {
} else if (isNode(obj)) {
return serialize(obj)
} else {
var constructor = 'Object'
Expand Down
4 changes: 4 additions & 0 deletions test/client/stringify.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,8 @@ describe('stringify', function () {

assert.deepEqual(__karma__.stringify([1, 2]), '[1, 2]')
})

it('should stringify object with property tagName as Object', function () {
assert(stringify({tagName: 'a'}).indexOf("{tagName: 'a'}") > -1)
})
})

0 comments on commit ba55afb

Please sign in to comment.