Skip to content
This repository was archived by the owner on Sep 21, 2021. It is now read-only.

Commit daf9425

Browse files
authored
Merge pull request #473 from devtools-html/oi-mode
Renders non-root nodes in a lesser mode than the root node.
2 parents 01dc51a + ad98ac6 commit daf9425

File tree

1 file changed

+17
-5
lines changed
  • packages/devtools-reps/src/object-inspector

1 file changed

+17
-5
lines changed

packages/devtools-reps/src/object-inspector/index.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,14 @@ type Grip = {
3636
actor: string
3737
};
3838

39+
type Mode = MODE.TINY | MODE.SHORT | MODE.LONG;
40+
3941
type Props = {
4042
autoExpandAll: boolean,
4143
autoExpandDepth: number,
4244
disabledFocus: boolean,
4345
itemHeight: number,
44-
mode: Object,
46+
mode: Mode,
4547
roots: Array<ObjectInspectorItem>,
4648
getObjectProperties: (actor:string) => any,
4749
loadObjectProperties: (value:Grip) => any,
@@ -236,7 +238,16 @@ class ObjectInspector extends Component {
236238
} else if (nodeIsMissingArguments(item) || unavailable) {
237239
objectValue = dom.span({ className: "unavailable" }, "(unavailable)");
238240
} else if (nodeHasProperties(item) || nodeIsPrimitive(item)) {
239-
objectValue = this.renderGrip(item, this.props);
241+
let mode;
242+
if (depth === 0) {
243+
mode = this.props.mode;
244+
} else {
245+
mode = this.props.mode === MODE.LONG
246+
? MODE.SHORT
247+
: MODE.TINY;
248+
}
249+
250+
objectValue = this.renderGrip(item, this.props, mode);
240251
}
241252

242253
const SINGLE_INDENT_WIDTH = 15;
@@ -306,12 +317,13 @@ class ObjectInspector extends Component {
306317

307318
renderGrip(
308319
item: ObjectInspectorItem,
309-
props: Props
320+
props: Props,
321+
mode: Mode = MODE.TINY
310322
) {
311323
const object = getValue(item);
312324
return Rep(Object.assign({}, props, {
313325
object,
314-
mode: props.mode || MODE.TINY
326+
mode,
315327
}));
316328
}
317329

@@ -330,7 +342,7 @@ class ObjectInspector extends Component {
330342

331343
let roots = this.getRoots();
332344
if (roots.length === 1 && nodeIsPrimitive(roots[0])) {
333-
return this.renderGrip(roots[0], this.props);
345+
return this.renderGrip(roots[0], this.props, this.props.mode);
334346
}
335347

336348
return Tree({

0 commit comments

Comments
 (0)