Skip to content

Commit

Permalink
Merge pull request #272 from huumanoid/fix-wrapper-tag
Browse files Browse the repository at this point in the history
Fix wrapper tag
  • Loading branch information
huumanoid authored Mar 23, 2017
2 parents 6a56af2 + d2a97a7 commit 9399d75
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ class ReactTooltip extends Component {
wrapper: 'div'
};

static supportedWrappers = {
'div': React.DOM.div,
'span': React.DOM.span
};
static supportedWrappers = ['div', 'span'];

constructor (props) {
super(props)
Expand Down Expand Up @@ -443,21 +440,23 @@ class ReactTooltip extends Component {
{'type-light': this.state.type === 'light'}
)

let wrapper = ReactTooltip.supportedWrappers[this.props.wrapper]
if (!wrapper) wrapper = ReactTooltip.supportedWrappers['div']
let Wrapper = this.props.wrapper
if (ReactTooltip.supportedWrappers.indexOf(Wrapper) < 0) {
Wrapper = ReactTooltip.defaultProps.wrapper
}

if (html) {
return (
<wrapper className={`${tooltipClass} ${extraClass}`}
<Wrapper className={`${tooltipClass} ${extraClass}`}
{...ariaProps}
data-id='tooltip'
dangerouslySetInnerHTML={{__html: placeholder}}></wrapper>
dangerouslySetInnerHTML={{__html: placeholder}}/>
)
} else {
return (
<wrapper className={`${tooltipClass} ${extraClass}`}
<Wrapper className={`${tooltipClass} ${extraClass}`}
{...ariaProps}
data-id='tooltip'>{placeholder}</wrapper>
data-id='tooltip'>{placeholder}</Wrapper>
)
}
}
Expand Down

0 comments on commit 9399d75

Please sign in to comment.