diff --git a/src/lib/JsonViewer.es6 b/src/lib/JsonViewer.es6
index 39fbd8e..f9305e2 100644
--- a/src/lib/JsonViewer.es6
+++ b/src/lib/JsonViewer.es6
@@ -73,7 +73,7 @@ function createEl(key, val, firstLevel)
if (val === null)
{
return `
- ${encode(key)}:
+ ${wrapKey(key)}
null
`;
}
@@ -81,7 +81,7 @@ function createEl(key, val, firstLevel)
{
var obj = `
- ${encode(key)}
+ ${firstLevel ? '' : wrapKey(key)}
${open} ${(val['erudaObjAbstract'] || '')}
`;
obj += jsonToHtml(val);
@@ -90,29 +90,39 @@ function createEl(key, val, firstLevel)
if (util.isNum(val) || util.isBool(val))
{
return `-
- ${encode(key)}:
+ ${wrapKey(key)}
${encode(val)}
`;
}
if (util.isStr(val) && util.startWith(val, 'function'))
{
return `-
- ${encode(key)}:
+ ${wrapKey(key)}
${val.length > 250 ? encode(val) : highlight(val, 'js')}
`;
}
if (val === '(...)' || val === '[circular]' || val === 'undefined' || val === 'Symbol')
{
return `-
- ${encode(key)}:
+ ${wrapKey(key)}
${val}
`;
}
return `-
- ${encode(key)}:
+ ${wrapKey(key)}
"${encode(val)}"
`;
}
+function wrapKey(key)
+{
+ var keyClass = 'eruda-key';
+ if (util.contain(LIGHTER_KEY, key)) keyClass = 'eruda-key-lighter';
+
+ return `${encode(key)}: `;
+}
+
+const LIGHTER_KEY = ['__proto__', 'constructor', 'toString', 'valueOf'];
+
var encode = str => util.escape(util.toStr(str));
\ No newline at end of file
diff --git a/src/lib/json.scss b/src/lib/json.scss
index aa482a5..1472324 100644
--- a/src/lib/json.scss
+++ b/src/lib/json.scss
@@ -46,6 +46,9 @@
.key {
color: #a71d5d;
}
+ .key-lighter {
+ color: #d391b5;
+ }
.expanded:before {
content: "";
width: 0;
diff --git a/src/lib/stringify.es6 b/src/lib/stringify.es6
index d4126cd..f6ec8bb 100644
--- a/src/lib/stringify.es6
+++ b/src/lib/stringify.es6
@@ -215,7 +215,7 @@ export default function stringify(obj, {
// https://docs.webplatform.org/wiki/dom/HTMLAllCollection
// Might cause a performance issue when stringify a dom element.
json = wrapStr('[object HTMLAllCollection]');
- } else if (type === '[object HTMLDocument]' && level > 0)
+ } else if (type === '[object HTMLDocument]' && level > 1)
{
// Same as reason above.
json = wrapStr('[object HTMLDocument]');