Skip to content

Commit 928e39d

Browse files
authored
Merge pull request #207 from cstuncsik/1.x
fix: show null and explicit undefined values
2 parents 99c9659 + 15b73c9 commit 928e39d

File tree

8 files changed

+25
-9
lines changed

8 files changed

+25
-9
lines changed

example/Basic.vue

+3-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ import VueJsonPretty from 'src';
9393
9494
const defaultData = {
9595
status: 200,
96-
error: '',
96+
text: '',
97+
error: null,
98+
config: undefined,
9799
data: [
98100
{
99101
news_id: 51184,

example/Editable.vue

+3-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ import VueJsonPretty from 'src';
5555
5656
const defaultData = {
5757
status: 200,
58-
error: '',
58+
text: '',
59+
error: null,
60+
config: undefined,
5961
data: [
6062
{
6163
news_id: 51184,

example/SelectControl.vue

+3-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ import VueJsonPretty from 'src';
105105
106106
const defaultData = {
107107
status: 200,
108-
error: '',
108+
text: '',
109+
error: null,
110+
config: undefined,
109111
data: [
110112
{
111113
news_id: 51184,

example/VirtualList.vue

+3-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ import VueJsonPretty from 'src';
4747
4848
const defaultData = {
4949
status: 200,
50-
error: '',
50+
text: '',
51+
error: null,
52+
config: undefined,
5153
data: Array.from(Array(1000)).map((item, index) => ({
5254
news_id: index,
5355
title: 'iPhone X Review: Innovative future with real black technology',

src/components/TreeNode/index.vue

+5-3
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,11 @@ export default {
175175
},
176176
177177
defaultValue() {
178-
const str = (this.node?.content ?? '') + '';
179-
const text = this.dataType === 'string' ? `"${str}"` : str;
180-
return text;
178+
let value = this.node?.content;
179+
if(value === null || value === undefined) {
180+
value += '';
181+
}
182+
return this.dataType === 'string' ? `"${value}"` : value
181183
},
182184
},
183185
methods: {

src/components/TreeNode/styles.less

+4
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@
5555
.gen-value-style(@color-null);
5656
}
5757

58+
.@{css-prefix}-value-undefined {
59+
.gen-value-style(@color-undefined);
60+
}
61+
5862
.@{css-prefix}-value-number {
5963
.gen-value-style(@color-number);
6064
}

src/themes.less

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
@color-info: #1d8ce0;
77
@color-error: #ff4949;
88
@color-success: #13ce66;
9+
@color-nil: #D55FDE;
910

1011
/* field values color */
1112
@color-string: @color-success;
1213
@color-number: @color-info;
1314
@color-boolean: @color-info;
14-
@color-null: @color-error;
15+
@color-null: @color-nil;
16+
@color-undefined: @color-nil;
1517

1618
/* highlight */
1719
@highlight-bg-color: #e6f7ff;

src/utils/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export function arrFlat(arr) {
8484
}
8585

8686
export function cloneDeep(source, hash = new WeakMap()) {
87-
if (source === null) return source;
87+
if (source === null || source === undefined) return source;
8888
if (source instanceof Date) return new Date(source);
8989
if (source instanceof RegExp) return new RegExp(source);
9090
if (typeof source !== 'object') return source;

0 commit comments

Comments
 (0)