Skip to content

Commit

Permalink
Merge pull request karma-runner#2155 from maksimr/patch-2139
Browse files Browse the repository at this point in the history
fix(client): does not throws an error for non DOM object that has `ta…
  • Loading branch information
dignifiedquire committed May 28, 2016
2 parents 13368e6 + ba55afb commit ca95553
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 ca95553

Please sign in to comment.