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

Commit 2d4546d

Browse files
committed
Add a noGrip prop to force object to be rendered using non-remote reps.
Modify the getRep and supportsObject functions so we can pass this noGrip property to it. Add tests in the Obj reps which try to render stubs representing different remote object, with the noGrip prop, and makes sure it uses the Obj rep, and not the "remote" one.
1 parent a3641a6 commit 2d4546d

23 files changed

+191
-47
lines changed

packages/devtools-reps/src/reps/attribute.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ function getTitle(grip) {
4848
}
4949

5050
// Registration
51-
function supportsObject(grip, type) {
52-
if (!isGrip(grip)) {
51+
function supportsObject(grip, type, noGrip = false) {
52+
if (noGrip === true || !isGrip(grip)) {
5353
return false;
5454
}
5555

packages/devtools-reps/src/reps/comment-node.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ function CommentNode(props) {
4242
}
4343

4444
// Registration
45-
function supportsObject(object, type) {
46-
if (!isGrip(object)) {
45+
function supportsObject(object, type, noGrip = false) {
46+
if (noGrip === true || !isGrip(object)) {
4747
return false;
4848
}
4949
return object.preview && object.preview.nodeType === nodeConstants.COMMENT_NODE;

packages/devtools-reps/src/reps/date-time.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ function getTitle(props, grip) {
4545
}
4646

4747
// Registration
48-
function supportsObject(grip, type) {
49-
if (!isGrip(grip)) {
48+
function supportsObject(grip, type, noGrip = false) {
49+
if (noGrip === true || !isGrip(grip)) {
5050
return false;
5151
}
5252

packages/devtools-reps/src/reps/document.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ function getTitle(props, grip) {
4747
}
4848

4949
// Registration
50-
function supportsObject(object, type) {
51-
if (!isGrip(object)) {
50+
function supportsObject(object, type, noGrip = false) {
51+
if (noGrip === true || !isGrip(object)) {
5252
return false;
5353
}
5454

packages/devtools-reps/src/reps/element-node.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ function getElements(grip, mode) {
130130
}
131131

132132
// Registration
133-
function supportsObject(object, type) {
134-
if (!isGrip(object)) {
133+
function supportsObject(object, type, noGrip = false) {
134+
if (noGrip === true || !isGrip(object)) {
135135
return false;
136136
}
137137
return object.preview && object.preview.nodeType === nodeConstants.ELEMENT_NODE;

packages/devtools-reps/src/reps/error.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ function ErrorRep(props) {
4646
}
4747

4848
// Registration
49-
function supportsObject(object, type) {
50-
if (!isGrip(object)) {
49+
function supportsObject(object, type, noGrip = false) {
50+
if (noGrip === true || !isGrip(object)) {
5151
return false;
5252
}
5353
return (object.preview && type === "Error");

packages/devtools-reps/src/reps/event.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ function getTitle(props) {
8787
}
8888

8989
// Registration
90-
function supportsObject(grip, type) {
91-
if (!isGrip(grip)) {
90+
function supportsObject(grip, type, noGrip = false) {
91+
if (noGrip === true || !isGrip(grip)) {
9292
return false;
9393
}
9494

packages/devtools-reps/src/reps/function.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ function renderParams(props) {
7575
}
7676

7777
// Registration
78-
function supportsObject(grip, type) {
79-
if (!isGrip(grip)) {
78+
function supportsObject(grip, type, noGrip = false) {
79+
if (noGrip === true || !isGrip(grip)) {
8080
return (type == "function");
8181
}
8282

packages/devtools-reps/src/reps/grip-array.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ function getEmptySlotsElement(number) {
185185
return `<${number} empty slot${number > 1 ? "s" : ""}>`;
186186
}
187187

188-
function supportsObject(grip, type) {
189-
if (!isGrip(grip)) {
188+
function supportsObject(grip, type, noGrip = false) {
189+
if (noGrip === true || !isGrip(grip)) {
190190
return false;
191191
}
192192

packages/devtools-reps/src/reps/grip-map.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ function getEntriesIndexes(entries, max, filter) {
192192
}, []);
193193
}
194194

195-
function supportsObject(grip, type) {
196-
if (!isGrip(grip)) {
195+
function supportsObject(grip, type, noGrip = false) {
196+
if (noGrip === true || !isGrip(grip)) {
197197
return false;
198198
}
199199
return (grip.preview && grip.preview.kind == "MapLike");

0 commit comments

Comments
 (0)