Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

jQuery.print({a:1}) => "{ a: 1 }"

  • Loading branch information...
commit 49c052a45d1fff7ff49c1ec5381260986b62fc55 1 parent f586f5b
@tmm1 tmm1 authored
Showing with 5 additions and 3 deletions.
  1. +5 −3 lib/jquery.print.js
View
8 lib/jquery.print.js
@@ -21,13 +21,14 @@
if (obj.length > max)
result.push('... ' + (obj.length - max) + ' more')
- return "[" + result.join(", ") + "]";
+ if (result.length == 0) return "[]"
+ return "[ " + result.join(", ") + " ]"
} else if (obj instanceof HTMLElement) {
return "<" + obj.tagName.toLowerCase() +
(obj.className != "" ? " class='" + obj.className + "'" : "") +
(obj.id != "" ? " id='" + obj.id + "'" : "") +
- ">";
+ ">"
} else if (obj instanceof jQuery) {
var result = []
@@ -39,7 +40,8 @@
for (var k in obj) {
result.push(k + ": " + $.print(obj[k]))
}
- return "{" + result.join(", ") + "}"
+ if (result.length == 0) return "{}"
+ return "{ " + result.join(", ") + " }"
// XXX "abc" instanceof String # => false
} else if (obj instanceof String) {
Please sign in to comment.
Something went wrong with that request. Please try again.