Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure data-html is converted to bool type #104

Merged
merged 1 commit into from
May 19, 2016

Conversation

antoniodgonzalez
Copy link
Contributor

When using data-html attribute, this value was assigned to the html state attribute without ensuring the bool type, so it was being assigned as a string "true" or "false".

Later, this value was accessed with the code:
if (html) {
this was evaluating always to true and causing the content to not being encoded.

Applied code to ensure bool value, similar to the code applied for the data-border attribute.

@wwayne
Copy link
Collaborator

wwayne commented May 19, 2016

If the user wants to show a html tooltip on a specific element, for example:

<p data-tip data-html='<a>tooltip</a>'></p>
<ReactTooltip />

it won't show anything because e.currentTarget.getAttribute('data-html') === 'true' || this.props.html || false will return false

@antoniodgonzalez
Copy link
Contributor Author

From the documentation, I understood that this parameter should be boolean (true/false)
This same example appears in the documentation as:

<p data-tip="<p>HTML tooltip</p>" data-html={true}></p> or <ReactTooltip html={true} />

By reviewing the part of the code that handles this option, it seems that it is always using the placeholder, encoded or not depending on the html boolean value.

    if (html) {
      return (
        <div className={tooltipClass + ' ' + extraClass} data-id='tooltip' dangerouslySetInnerHTML={{__html: placeholder}}></div>
      )
    } else {
      const content = this.props.children ? this.props.children : placeholder
      return (
        <div className={tooltipClass + ' ' + extraClass} data-id='tooltip'>{content}</div>
      )
    }

@wwayne
Copy link
Collaborator

wwayne commented May 19, 2016

Hmm. my bad, I didn't check it carefully, yeah you're right, thanks

@wwayne wwayne merged commit 4e2bc77 into ReactTooltip:master May 19, 2016
@antoniodgonzalez
Copy link
Contributor Author

Thanks :)

Related to this, I noticed that other number attributes data-delay-show and data-delay-hide could potentially have the same issue, as they are not being converted to number. But didn't check myself and not sure if it is an actual problem.

@wwayne
Copy link
Collaborator

wwayne commented May 19, 2016

It's ok, because they have been converted to Int before using

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants