mirror of
https://github.com/liriliri/eruda.git
synced 2026-02-02 09:49:00 +08:00
Fix: Small bugs
This commit is contained in:
@@ -1,5 +1,13 @@
|
||||
let mark = [];
|
||||
|
||||
function exports(css)
|
||||
{
|
||||
for (let i = 0, len = mark.length; i < len; i++)
|
||||
{
|
||||
if (mark[i] === css) return;
|
||||
}
|
||||
mark.push(css);
|
||||
|
||||
var container = exports.container || document.head,
|
||||
style = document.createElement('style');
|
||||
|
||||
|
||||
@@ -65,6 +65,8 @@ export default class Log
|
||||
if (util.isStr(arg)) return false;
|
||||
if (util.isBool(arg)) return false;
|
||||
if (util.isNum(arg)) return false;
|
||||
if (util.isNull(arg)) return false;
|
||||
if (util.isUndef(arg)) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -128,7 +128,7 @@ export default class Elements extends Tool
|
||||
}
|
||||
}).on('click', '.eruda-breadcrumb', () =>
|
||||
{
|
||||
let data = this._elData || JSON.parse(stringify(this._curEl)),
|
||||
let data = this._elData || JSON.parse(stringify(this._curEl, {getterVal: true})),
|
||||
sources = parent.get('sources');
|
||||
|
||||
this._elData = data;
|
||||
|
||||
@@ -5,6 +5,8 @@ export default class JsonViewer
|
||||
{
|
||||
constructor(data, $el)
|
||||
{
|
||||
util.evalCss(require('./json.scss'));
|
||||
|
||||
this._data = [data];
|
||||
this._$el = $el;
|
||||
|
||||
@@ -97,14 +99,21 @@ function createEl(key, val, firstLevel)
|
||||
return `<li>
|
||||
<span class="eruda-key">${encode(key)}: </span>
|
||||
<span class="eruda-function">${val.length > 250 ? encode(val) : highlight(val, 'js')}</span>
|
||||
</li>`
|
||||
</li>`;
|
||||
}
|
||||
if (val === '(...)' || val === '[circular]')
|
||||
{
|
||||
return `<li>
|
||||
<span class="eruda-key">${encode(key)}: </span>
|
||||
<span class="eruda-special">${val}</span>
|
||||
</li>`
|
||||
</li>`;
|
||||
}
|
||||
if (val === 'undefined')
|
||||
{
|
||||
return `<li>
|
||||
<span class="eruda-key">${encode(key)}: </span>
|
||||
<span class="eruda-undefined">undefined</span>
|
||||
</li>`;
|
||||
}
|
||||
|
||||
return `<li>
|
||||
|
||||
77
src/lib/json.scss
Normal file
77
src/lib/json.scss
Normal file
@@ -0,0 +1,77 @@
|
||||
@import "../style/variable";
|
||||
@import "../style/mixin";
|
||||
|
||||
.container .json {
|
||||
@include overflow-auto(x);
|
||||
cursor: default;
|
||||
font-family: $font-family-code;
|
||||
font-size: $font-size-s;
|
||||
line-height: 1.2;
|
||||
background: #fff;
|
||||
min-height: 100%;
|
||||
&, ul {
|
||||
list-style: none !important;
|
||||
}
|
||||
ul {
|
||||
padding: 0 !important;
|
||||
padding-left: 20px !important;
|
||||
margin: 0 !important;
|
||||
}
|
||||
li {
|
||||
position: relative;
|
||||
white-space: nowrap;
|
||||
}
|
||||
& > li > .key,
|
||||
& .array .key {
|
||||
display: none;
|
||||
}
|
||||
.array .object .key {
|
||||
display: inline;
|
||||
}
|
||||
.null {
|
||||
color: #0086b3;
|
||||
}
|
||||
.string {
|
||||
color: #183691;
|
||||
}
|
||||
.number {
|
||||
color: #0086b3;
|
||||
}
|
||||
.boolean {
|
||||
color: #0086b3;
|
||||
}
|
||||
.special, .undefined {
|
||||
color: $gray;
|
||||
}
|
||||
.key {
|
||||
color: #a71d5d;
|
||||
}
|
||||
.expanded:before {
|
||||
content: "";
|
||||
width: 0;
|
||||
height: 0;
|
||||
border: 4px solid transparent;
|
||||
position: absolute;
|
||||
border-top-color: $gray;
|
||||
left: -12px;
|
||||
top: 5px;
|
||||
}
|
||||
.collapsed:before {
|
||||
content: "";
|
||||
border-left-color: $gray;
|
||||
border-top-color: transparent;
|
||||
left: -10px;
|
||||
top: 3px;
|
||||
}
|
||||
li .collapsed ~ .close:before {
|
||||
content: "... ";
|
||||
color: #999;
|
||||
}
|
||||
.hidden ~ ul {
|
||||
display: none;
|
||||
}
|
||||
span {
|
||||
position: static !important;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -534,8 +534,16 @@ module.exports = (function ()
|
||||
|
||||
var evalCss = _.evalCss = (function ()
|
||||
{
|
||||
let mark = [];
|
||||
|
||||
function exports(css)
|
||||
{
|
||||
for (let i = 0, len = mark.length; i < len; i++)
|
||||
{
|
||||
if (mark[i] === css) return;
|
||||
}
|
||||
mark.push(css);
|
||||
|
||||
var container = exports.container || document.head,
|
||||
style = document.createElement('style');
|
||||
|
||||
|
||||
@@ -46,74 +46,3 @@
|
||||
color: $green;
|
||||
}
|
||||
|
||||
.container .json {
|
||||
@include overflow-auto(x);
|
||||
cursor: default;
|
||||
font-family: $font-family-code;
|
||||
font-size: $font-size-s;
|
||||
line-height: 1.2;
|
||||
background: #fff;
|
||||
min-height: 100%;
|
||||
&, ul {
|
||||
list-style: none !important;
|
||||
}
|
||||
ul {
|
||||
padding: 0 !important;
|
||||
padding-left: 20px !important;
|
||||
margin: 0 !important;
|
||||
}
|
||||
li {
|
||||
position: relative;
|
||||
white-space: nowrap;
|
||||
}
|
||||
& > li > .key,
|
||||
& .array .key {
|
||||
display: none;
|
||||
}
|
||||
.array .object .key {
|
||||
display: inline;
|
||||
}
|
||||
.null {
|
||||
color: #0086b3;
|
||||
}
|
||||
.string {
|
||||
color: #183691;
|
||||
}
|
||||
.number {
|
||||
color: #0086b3;
|
||||
}
|
||||
.boolean {
|
||||
color: #0086b3;
|
||||
}
|
||||
.key {
|
||||
color: #a71d5d;
|
||||
}
|
||||
.expanded:before {
|
||||
content: "";
|
||||
width: 0;
|
||||
height: 0;
|
||||
border: 4px solid transparent;
|
||||
position: absolute;
|
||||
border-top-color: $gray;
|
||||
left: -12px;
|
||||
top: 5px;
|
||||
}
|
||||
.collapsed:before {
|
||||
content: "";
|
||||
border-left-color: $gray;
|
||||
border-top-color: transparent;
|
||||
left: -10px;
|
||||
top: 3px;
|
||||
}
|
||||
li .collapsed ~ .close:before {
|
||||
content: "... ";
|
||||
color: #999;
|
||||
}
|
||||
.hidden ~ ul {
|
||||
display: none;
|
||||
}
|
||||
span {
|
||||
position: static !important;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user