File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,11 @@ import { createElement } from 'react'
33function mapChild ( child , i , depth ) {
44 if ( child . tagName ) {
55 const props = Object . assign ( { key : 'lo-' + depth + '-' + i } , child . properties )
6+
7+ if ( Array . isArray ( props . className ) ) {
8+ props . className = props . className . join ( ' ' )
9+ }
10+
611 const children = child . children ? child . children . map ( mapWithDepth ( depth + 1 ) ) : null
712
813 return createElement ( child . tagName , props , children )
Original file line number Diff line number Diff line change @@ -86,6 +86,14 @@ describe('react-lowlight', () => {
8686 ] . join ( '' )
8787 )
8888 } )
89+
90+ it ( 'should properly join array-based class names in child elements' , ( ) => {
91+ const code = 'function foo() {}'
92+
93+ expect ( render ( { value : code , language : 'js' } , { withWrapper : true } ) ) . toBe (
94+ '<pre class="lowlight"><code class="hljs js"><span class="hljs-keyword">function</span> <span class="hljs-title function_">foo</span>(<span class="hljs-params"></span>) {}</code></pre>'
95+ )
96+ } )
8997} )
9098
9199function render ( props , options = { } ) {
You can’t perform that action at this time.
0 commit comments