Bug 1314573 - Modify textNode Reps modes to match elementNodeRep; r=Honza
On elementNodeRep, we have different outputs for tiny and short modes, and
short and long modes are the same.
Since the current long mode of textNodeRep aren't used anywhere, we can do the
same, i.e. have a really small representation for tiny mode, and then the same
rendering for short and long modes.
Modify tests to adapt them to the new rendering.
MozReview-Commit-ID: BRA7iADkn1C
--- a/devtools/client/shared/components/reps/text-node.js
+++ b/devtools/client/shared/components/reps/text-node.js
@@ -27,22 +27,23 @@ define(function (require, exports, modul
mode: React.PropTypes.string,
},
getTextContent: function (grip) {
return cropString(grip.preview.textContent);
},
getTitle: function (grip) {
+ const title = "#text";
if (this.props.objectLink) {
return this.props.objectLink({
object: grip
- }, "#text ");
+ }, title);
}
- return "";
+ return title;
},
render: function () {
let grip = this.props.object;
let mode = this.props.mode || "short";
let baseConfig = {className: "objectBox objectBox-textNode"};
if (this.props.onDOMNodeMouseOver) {
@@ -52,43 +53,27 @@ define(function (require, exports, modul
}
if (this.props.onDOMNodeMouseOut) {
Object.assign(baseConfig, {
onMouseOut: this.props.onDOMNodeMouseOut
});
}
- if (mode == "short" || mode == "tiny") {
- return (
- DOM.span(baseConfig,
- this.getTitle(grip),
- DOM.span({className: "nodeValue"},
- "\"" + this.getTextContent(grip) + "\""
- )
- )
- );
+ if (mode == "tiny") {
+ return DOM.span(baseConfig, this.getTitle(grip));
}
- let objectLink = this.props.objectLink || DOM.span;
return (
DOM.span(baseConfig,
this.getTitle(grip),
- objectLink({
- object: grip
- }, "<"),
- DOM.span({className: "nodeTag"}, "TextNode"),
- " textContent=\"",
DOM.span({className: "nodeValue"},
- this.getTextContent(grip)
- ),
- "\"",
- objectLink({
- object: grip
- }, ">;")
+ " ",
+ `"${this.getTextContent(grip)}"`
+ )
)
);
},
});
// Registration
function supportsObject(grip, type) {
--- a/devtools/client/shared/components/test/mochitest/test_reps_text-node.html
+++ b/devtools/client/shared/components/test/mochitest/test_reps_text-node.html
@@ -55,62 +55,60 @@ window.onload = Task.async(function* ()
} catch (e) {
ok(false, "Got an error: " + DevToolsUtils.safeErrorString(e));
} finally {
SimpleTest.finish();
}
function testRendering() {
const stub = gripStubs.get("testRendering");
- const defaultShortOutput = `"hello world"`;
- const defaultLongOutput = `<TextNode textContent="hello world">;`;
+ const defaultOutput = `#text "hello world"`;
const modeTests = [
{
mode: undefined,
- expectedOutput: defaultShortOutput,
+ expectedOutput: defaultOutput,
},
{
mode: "tiny",
- expectedOutput: defaultShortOutput,
+ expectedOutput: "#text",
},
{
mode: "short",
- expectedOutput: defaultShortOutput,
+ expectedOutput: defaultOutput,
},
{
mode: "long",
- expectedOutput: defaultLongOutput,
+ expectedOutput: defaultOutput,
}
];
testRepRenderModes(modeTests, "testRendering", TextNode, stub);
}
function testRenderingWithEOL() {
const stub = gripStubs.get("testRenderingWithEOL");
- const defaultShortOutput = `"hello\nworld"`;
- const defaultLongOutput = `<TextNode textContent="hello\nworld">;`;
+ const defaultOutput = `#text "hello\nworld"`;
const modeTests = [
{
mode: undefined,
- expectedOutput: defaultShortOutput,
+ expectedOutput: defaultOutput,
},
{
mode: "tiny",
- expectedOutput: defaultShortOutput,
+ expectedOutput: "#text",
},
{
mode: "short",
- expectedOutput: defaultShortOutput,
+ expectedOutput: defaultOutput,
},
{
mode: "long",
- expectedOutput: defaultLongOutput,
+ expectedOutput: defaultOutput,
}
];
testRepRenderModes(modeTests, "testRenderingWithEOL", TextNode, stub);
}
function testOnMouseOver() {
const stub = gripStubs.get("testRendering");