Skip to content

Commit

Permalink
release: 0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
azaslavsky committed Jan 7, 2015
1 parent 2c94585 commit a74ca89
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 16 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "domjson",
"version": "0.0.1",
"version": "0.1.0",
"description": "Convert DOM trees into compact JSON objects, and vice versa, as fast as possible.",
"main": "dist/domJSON.js",
"license": "MIT",
Expand Down
35 changes: 22 additions & 13 deletions dist/domJSON.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"use strict";
var domJSON = {};
var metadata = {
domain: win.location.href || null,
href: win.location.href || null,
userAgent: window.navigator && window.navigator.userAgent ? window.navigator.userAgent : null,
version: "0.1.0"
};
Expand Down Expand Up @@ -196,7 +196,7 @@
var copyJSON = function(node, opts) {
var copy = {};
for (var n in node) {
if (node.hasOwnProperty(n) && typeof node[n] !== "function") {
if (typeof node[n] !== "undefined" && typeof node[n] !== "function" && n.charAt(0).toLowerCase() === n.charAt(0)) {
if (!(node[n] instanceof Object) || node[n] instanceof Array) {
if (opts.cull) {
if (node[n] || node[n] === 0 || node[n] === false) {
Expand Down Expand Up @@ -251,7 +251,7 @@
} else if (node.nodeType === 3 && !node.nodeValue.trim()) {
return null;
}
if (opts.attributes && node.hasOwnProperty("attributes")) {
if (opts.attributes && node.attributes) {
copy.attributes = attrJSON(node, opts);
}
if (opts.computedStyle && (style = styleJSON(node, opts))) {
Expand Down Expand Up @@ -306,8 +306,19 @@
copy = toJSON(node, options, 0);
if (options.metadata) {
output.meta = extend({}, metadata, {
options: options,
clock: new Date().getTime() - timer
clock: new Date().getTime() - timer,
date: new Date().toISOString(),
dimensions: {
inner: {
x: window.innerWidth,
y: window.innerHeight
},
outer: {
x: window.outerWidth,
y: window.outerHeight
}
},
options: options
});
output.node = copy;
} else {
Expand Down Expand Up @@ -350,12 +361,6 @@
case 9:
return doc.implementation.createHTMLDocument(data);

case 10:
if (data.hasOwnProperty("name") && data.hasOwnProperty("publicId") && data.hasOwnProperty("systemId")) {
return doc.implementation.createDocumentType(data.name, data.publicId, data.systemId);
}
return false;

case 11:
return doc;

Expand All @@ -371,8 +376,12 @@
return false;
}
for (var x in obj) {
if (!(obj[x] instanceof Object)) {
node[x] = obj[x];
if (!(obj[x] instanceof Object) && x !== "isContentEditable") {
try {
node[x] = obj[x];
} catch (e) {
continue;
}
}
}
var src;
Expand Down
2 changes: 1 addition & 1 deletion dist/domJSON.min.js

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "domjson",
"author": "Alex Zaslavsky <[email protected]>",
"version": "0.0.1",
"version": "0.1.0",
"description": "Convert DOM trees into compact JSON objects, and vice versa, as fast as possible.",
"contributors": [
{
Expand Down

0 comments on commit a74ca89

Please sign in to comment.