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

Commit

Permalink
don't serialize large arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
sorvell committed Jun 17, 2014
1 parent 144f914 commit 72ce109
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions elements/design-host/design-host.html
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
});

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

function serializePropertyValue(name, obj, indent, tab) {
var value = obj[name], type = typeof value;
Expand All @@ -154,8 +155,12 @@
value = '\'' + value + '\'';
break;
case 'object':
value = JSON.stringify(value, null, tab);
value = value.replace(/\n/g, '\n' + indent + tab);
if (Array.isArray(value) && value.length > MAX_SERIALIZE_ARRAY_LENGTH) {
value = null;
} else {
value = JSON.stringify(value, null, tab);
value = value.replace(/\n/g, '\n' + indent + tab);
}
break;
}
return name + ': ' + value;
Expand Down

0 comments on commit 72ce109

Please sign in to comment.