Skip to content

Commit a899656

Browse files
authored
fix(dangerMode): dont convert objects to HTML (#964)
1 parent e2b602f commit a899656

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

demo/App.jsx

+11-1
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,19 @@ export default class App extends Component {
238238
locked={this.state.locked}
239239
/>
240240
},
241+
{
242+
title: 'Raw HTML output',
243+
link: 'https://github.com/linuswillner/react-console-emulator/blob/master/demo/App.jsx#L244-L249',
244+
component: <Terminal
245+
style={globalStyles}
246+
commands={commands}
247+
welcomeMessage='This terminal should render raw HTML to stdout. Try running the `html` command to see what happens!'
248+
dangerMode
249+
/>
250+
},
241251
{
242252
title: 'Progress demo',
243-
link: 'https://github.com/linuswillner/react-console-emulator/blob/master/demo/App.jsx#L244-L271',
253+
link: 'https://github.com/linuswillner/react-console-emulator/blob/master/demo/App.jsx#L254-L281',
244254
component: <Terminal
245255
style={globalStyles}
246256
ref={this.progressTerminal}

demo/extra/config.js

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ export default {
2929
setTimeout(() => resolve('Finished!'), 1000)
3030
})
3131
}
32+
},
33+
html: {
34+
description: 'Returns a raw HTML string.',
35+
fn: async () => '<span style="color:#c386ff">Hello</span> <span style="color:#fa8072">World</span>'
3236
}
3337
},
3438
casingCommands: {

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"codecov": "codecov --disable=gcov",
1717
"test": "npm run lint && npm run test-coverage && npm run codecov",
1818
"test-local": "npm run lint && npm run test-coverage",
19+
"test-watch": "npm run test-local -- -- --watch",
1920
"test-coverage": "cross-env TEST=true jest --config jest.coverage.js",
2021
"test-nocoverage": "cross-env TEST=true jest --config jest.default.js",
2122
"prepublishOnly": "npm run compile"

src/TerminalMessage.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default class TerminalMessage extends Component {
1515
message: defaults(style, sourceStyles)
1616
}
1717

18-
return this.props.dangerMode
18+
return this.props.dangerMode && typeof content === 'string'
1919
? <div className={className} style={styles.message} {...html(content)}/>
2020
: <div className={className} style={styles.message}>{content}</div>
2121
}

0 commit comments

Comments
 (0)