Skip to content

Commit bbeeb79

Browse files
committed
Fixed Warning: Unknown prop "language" on <pre> tag
1 parent a81b8f8 commit bbeeb79

5 files changed

Lines changed: 24 additions & 8 deletions

File tree

dist/main.js

Lines changed: 9 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/main.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"main": "dist/main.js",
55
"author": "Brian Vaughn",
66
"user": "bvaughn",
7-
"version": "1.0.4",
7+
"version": "1.0.5",
88
"scripts": {
99
"build": "npm run build:website && npm run build:dist",
1010
"build:website": "npm run clean:website && NODE_ENV=production webpack --config webpack.config.website.js -p --bail",

src/Highlight.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import highlight from 'highlight.js'
55
export default class Highlight extends Component {
66
static propTypes = {
77
children: PropTypes.node.isRequired,
8-
language: PropTypes.string
8+
className: PropTypes.string,
9+
language: PropTypes.string,
10+
style: PropTypes.object
911
}
1012

1113
componentDidMount () {
@@ -18,10 +20,13 @@ export default class Highlight extends Component {
1820
}
1921

2022
render () {
21-
const { children, language } = this.props
23+
const { children, className, language, style } = this.props
2224

2325
return (
24-
<pre {...this.props}>
26+
<pre
27+
className={className}
28+
style={style}
29+
>
2530
<code
2631
className={language}
2732
ref='code'

src/Highlight.test.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ describe('Highlight', () => {
1111
<Highlight
1212
className='custom'
1313
language={language}
14+
style={{
15+
color: 'red'
16+
}}
1417
>
1518
{content}
1619
</Highlight>,
@@ -28,7 +31,8 @@ describe('Highlight', () => {
2831
expect(highlightDOMNode.querySelector('.hljs-comment').textContent).to.contain('// comment')
2932
})
3033

31-
it('should support additional props like :className', () => {
34+
it('should support additional props :className and :style', () => {
3235
expect(highlightDOMNode.className).to.contain('custom')
36+
expect(highlightDOMNode.style.color).to.equal('red')
3337
})
3438
})

0 commit comments

Comments
 (0)