File tree Expand file tree Collapse file tree 3 files changed +14
-4
lines changed Expand file tree Collapse file tree 3 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -56,8 +56,12 @@ function transformAttributes(attributes?: Attributes): Attributes {
5656
5757 const transformedAttributes : Attributes = { }
5858 Object . keys ( attributes ) . forEach ( ( key ) => {
59- if ( ! attributes [ key ] . startsWith ( 'on' ) && reactAttributesMap [ key ] ) {
60- transformedAttributes [ reactAttributesMap [ key ] ] = attributes [ key ]
59+ if ( ! key . startsWith ( 'on' ) ) {
60+ if ( reactAttributesMap [ key ] ) {
61+ transformedAttributes [ reactAttributesMap [ key ] ] = attributes [ key ]
62+ } else {
63+ transformedAttributes [ key ] = attributes [ key ]
64+ }
6165 }
6266 } )
6367 return transformedAttributes
Original file line number Diff line number Diff line change 1- import { render , shallow } from 'enzyme'
1+ import { render } from 'enzyme'
22import * as React from 'react'
33
44import * as htmldomToReact from '../src/index'
@@ -10,7 +10,7 @@ describe('Public API', () => {
1010
1111 describe ( '#parse' , ( ) => {
1212 it ( 'should convert a string to an array of react nodes' , ( ) => {
13- const elements = htmldomToReact . parse ( '<em><b>It\' is working</b></em>' )
13+ const elements = htmldomToReact . parse ( '<em key="1" ><b key="2" >It\' is working</b></em>' )
1414 const wrapper = render ( React . createElement ( 'div' , null , elements ) )
1515 expect ( wrapper . text ( ) ) . toEqual ( 'It\' is working' )
1616 expect ( wrapper . find ( 'em' ) ) . toHaveLength ( 1 )
Original file line number Diff line number Diff line change @@ -90,7 +90,13 @@ describe('React', () => {
9090 it ( 'should render nested tags' , ( ) => {
9191 const element = {
9292 children : [ {
93+ attributes : {
94+ key : '1' ,
95+ } ,
9396 children : [ {
97+ attributes : {
98+ key : '2' ,
99+ } ,
94100 name : '#text' ,
95101 type : NodeType . TEXT_NODE ,
96102 value : 'text' ,
You can’t perform that action at this time.
0 commit comments