Skip to content
This repository has been archived by the owner on May 2, 2018. It is now read-only.

Commit

Permalink
Merge pull request #132 from devtools-html/faster
Browse files Browse the repository at this point in the history
Cleanup and small improvements
  • Loading branch information
nchevobbe authored Apr 20, 2017
2 parents 8d3aa98 + fa5282d commit 455e5a9
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/reps/grip-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ function getEntries(props, entries, indexes) {
object: value,
// Do not add a trailing comma on the last entry
// if there won't be a "more..." item.
delim: (i < indexes.length - 1 || indexes.length < entries.length) ? ", " : "",
delim: (i < indexes.length - 1 || indexes.length < entries.length) ? ", " : null,
mode: MODE.TINY,
objectLink,
onDOMNodeMouseOver,
Expand Down
24 changes: 10 additions & 14 deletions src/reps/grip.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,33 +142,29 @@ function propIterator(props, object, max) {
* @return {Array} Props.
*/
function getProps(componentProps, properties, indexes, truncate, suppressQuotes) {
let propsArray = [];

// Make indexes ordered by ascending.
indexes.sort(function (a, b) {
return a - b;
});

indexes.forEach((i) => {
let name = Object.keys(properties)[i];
const propertiesKeys = Object.keys(properties);
return indexes.map((i) => {
let name = propertiesKeys[i];
let value = getPropValue(properties[name]);

let propRepProps = Object.assign({}, componentProps, {
return PropRep(Object.assign({}, componentProps, {
mode: MODE.TINY,
name: name,
name,
object: value,
equal: ": ",
delim: i !== indexes.length - 1 || truncate ? ", " : "",
delim: i !== indexes.length - 1 || truncate ? ", " : null,
defaultRep: Grip,
// Do not propagate title to properties reps
title: undefined,
// Do not propagate title and objectLink to properties reps
title: null,
objectLink: null,
suppressQuotes,
});
delete propRepProps.objectLink;
propsArray.push(PropRep(propRepProps));
}));
});

return propsArray;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/reps/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ function getPropsArray(object, truncated) {
name,
object: object[name],
equal: ": ",
delim: i !== objectKeys.length - 1 || truncated ? ", " : "",
delim: i !== objectKeys.length - 1 || truncated ? ", " : null,
}));
}

Expand Down
4 changes: 2 additions & 2 deletions src/reps/promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const {
wrapRender,
} = require("./rep-utils");

const PropRep = React.createFactory(require("./prop-rep"));
const PropRep = require("./prop-rep");
const { MODE } = require("./constants");
// Shortcuts
const { span } = React.DOM;
Expand Down Expand Up @@ -79,7 +79,7 @@ function getProps(props, promiseState) {
name: `<${key}>`,
object,
equal: ": ",
delim: i < keys.length - 1 ? ", " : "",
delim: i < keys.length - 1 ? ", " : null,
suppressQuotes: true,
}));
});
Expand Down
11 changes: 8 additions & 3 deletions src/reps/prop-rep.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,21 @@ function PropRep(props) {
}));
}

let delimElement;
if (delim) {
delimElement = span({
"className": "objectComma"
}, delim);
}

return (
span({},
key,
span({
"className": "objectEqual"
}, equal),
Rep(Object.assign({}, props)),
span({
"className": "objectComma"
}, delim)
delimElement,
)
);
}
Expand Down

0 comments on commit 455e5a9

Please sign in to comment.