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 #136 from janodvarko/bug1307879
Browse files Browse the repository at this point in the history
Fix and export getGripPreviewItems() function
  • Loading branch information
nchevobbe authored Apr 24, 2017
2 parents 1fca017 + 97bbc50 commit bd50321
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const {
parseURLParams,
getSelectableInInspectorGrips,
maybeEscapePropertyName,
getGripPreviewItems,
} = require("./reps/rep-utils");

module.exports = {
Expand All @@ -17,4 +18,5 @@ module.exports = {
parseURLEncodedText,
parseURLParams,
getSelectableInInspectorGrips,
getGripPreviewItems,
};
11 changes: 10 additions & 1 deletion src/reps/rep-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,11 +362,19 @@ function getGripPreviewItems(grip) {
return [grip.preview.target];
}

// RegEx Grip
if (grip.displayString) {
return [grip.displayString];
}

// Generic Grip
if (grip.preview && grip.preview.ownProperties) {
let propertiesValues = Object.values(grip.preview.ownProperties)
.map(property => property.value || property);

let propertyKeys = Object.keys(grip.preview.ownProperties);
propertiesValues = propertiesValues.concat(propertyKeys);

// ArrayBuffer Grip
if (grip.preview.safeGetterValues) {
propertiesValues = propertiesValues.concat(
Expand All @@ -383,7 +391,7 @@ function getGripPreviewItems(grip) {

/**
* Returns a new element wrapped with a component, props.objectLink if it exists,
* or a span if there are multiple childs, or directly the child if only one is passed.
* or a span if there are multiple children, or directly the child if only one is passed.
*
* @param {Object} props A Rep "props" object that may contain `objectLink`
* and `object` properties.
Expand Down Expand Up @@ -427,4 +435,5 @@ module.exports = {
getSelectableInInspectorGrips,
maybeEscapePropertyName,
safeObjectLink,
getGripPreviewItems,
};

0 comments on commit bd50321

Please sign in to comment.