Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Commit

Permalink
Fixes #56
Browse files Browse the repository at this point in the history
  • Loading branch information
sorvell committed Jul 23, 2014
1 parent f959b1c commit 1fa1eb2
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions elements/design-host/design-host.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@
var props = [];
Object.keys(this.model).forEach(function(k) {
if (serializeScriptBlacklist.indexOf(k) < 0) {
props.push(serializePropertyValue(k, this.model, indent, tab));
var propString = serializePropertyValue(k, this.model, indent, tab);
if (propString) {
props.push(propString);
}
}
}, this);
s += props.join(',\n' + indent + tab);
Expand Down Expand Up @@ -146,7 +149,7 @@
});

var serializeScriptBlacklist = ['$'];
var MAX_SERIALIZE_ARRAY_LENGTH = 5;
var MAX_SERIALIZE_LENGTH = 5;

function serializePropertyValue(name, obj, indent, tab) {
var value = obj[name], type = typeof value;
Expand All @@ -158,11 +161,17 @@
value = '\'' + value + '\'';
break;
case 'object':
if (Array.isArray(value) && value.length > MAX_SERIALIZE_ARRAY_LENGTH) {
var length = value ? (Array.isArray(value) ? value.length :
Object.keys(value).length) : 0;
if (length > MAX_SERIALIZE_LENGTH) {
value = null;
} else {
value = JSON.stringify(value, null, tab);
value = value.replace(/\n/g, '\n' + indent + tab);
try {
value = JSON.stringify(value, null, tab);
value = value.replace(/\n/g, '\n' + indent + tab);
} catch(e) {
value = null;
}
}
break;
}
Expand Down

0 comments on commit 1fa1eb2

Please sign in to comment.