Skip to content

Commit d2a97a7

Browse files
committed
Make mergeable
2 parents 49fece0 + 6a56af2 commit d2a97a7

File tree

7 files changed

+96
-28
lines changed

7 files changed

+96
-28
lines changed

AUTHORS.txt

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
achernetsky <alexander.chernetsky@gmail.com>
2+
Adam Weber <adamweber01@gmail.com>
3+
af7 <af7@users.noreply.github.com>
4+
Andre Junges <andrejunges@outlook.com>
5+
Anton Strömkvist <anton@lutic.org>
6+
Antonio D. Gonzalez <antonio.gonzalez@xepient.com>
7+
Anuj <oyeanuj@users.noreply.github.com>
8+
Bez Reyhan <bezreyhan@gmail.com>
9+
Boris Kotov <boris.kotov@gmail.com>
10+
brandly <brandly13@gmail.com>
11+
Brian T. Rice <brian@awakenetworks.com>
12+
Cole Chamberlain <cole.chamberlain@gmail.com>
13+
conorhastings <conor@socialtables.com>
14+
Dave Justice <davejustishh@gmail.com>
15+
Doron Pagot <doronpagot@gmail.com>
16+
Eugene Pokidov <pokidovea@gmail.com>
17+
Gauthier JACQUES <jacqg@citobi.eu>
18+
Godson Ukpere <godson.ukpere@gmail.com>
19+
huumanoid <huumanoid@hotmail.com>
20+
Ian Johnson <enjalot@gmail.com>
21+
Idan Gazit <idan@gazit.me>
22+
Ilker Guller <ilker.guller@dojomadness.com>
23+
Joel Burget <joelburget@gmail.com>
24+
johnamiahford <johnamiahford@gmail.com>
25+
Jonathan Beller <jon@mark43.com>
26+
Maksim Kondratyuk <Maksim.Kondratyuk@check24.de>
27+
Martin Ciparelli <mciparelli@gmail.com>
28+
Mathew Kurian <bluejamesbond@gmail.com>
29+
Mathew Kurian <mkurian@salesforce.com>
30+
Mikkel Christiansen <mc@flextown.com>
31+
Mikko Piuhola <mikko.piuhola@metropolia.fi>
32+
Mikko Piuhola <mikkopiu@users.noreply.github.com>
33+
Monterra <domi.sumer@gmail.com>
34+
nd0ut <nd0ut.me@gmail.com>
35+
Nikolay <nikmail88@gmail.com>
36+
Olena Sovyn <olenasovyn@gmail.com>
37+
oluckyman <gelias.gbelsky@gmail.com>
38+
ondy1985 <ondy1985@gmail.com>
39+
Petr Brzek <petrbrzek@abdoc.net>
40+
rnons <remotenonsense@gmail.com>
41+
Rob Zolkos <rob@zolkos.com>
42+
Royee Shemesh <royee_shemesh@intuit.com>
43+
ruffle1986 <ftamas.mail@gmail.com>
44+
Sasha Bayan <sasha_bayan@apple.com>
45+
Thomas BRILLARD <thomb45@gmail.com>
46+
Tom S <thom.schell@gmail.com>
47+
Tomasz Netczuk <netczuk.tomasz@gmail.com>
48+
Wang Zixiao <wayne.wang0821@gmail.com>
49+
İlker Güller <Sly777@users.noreply.github.com>

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
## Change Log
22

3+
### 3.2.9 (2017/03/20 15:37 +00:00)
4+
- [#236](https://github.com/wwayne/react-tooltip/pull/236) escape backslash in getTargetArray method (@rnons)
5+
36
### 3.2.7 (2017/02/17 07:24 +00:00)
47
- [#262](https://github.com/wwayne/react-tooltip/pull/262) Fix nodelist converte in safari (@wwayne)
58
- [#260](https://github.com/wwayne/react-tooltip/pull/260) Fix NodeList to Array convertion (@huumanoid)

README.md

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
[download-image]: https://img.shields.io/npm/dm/react-tooltip.svg?style=flat-square
88
[download-url]: https://npmjs.org/package/react-tooltip
99

10+
## Maintainers
11+
[huumanoid](https://github.com/huumanoid)
12+
1013
## Installation
1114

1215
```sh
@@ -27,7 +30,7 @@ import ReactTooltip from 'react-tooltip'
2730
<p data-tip="hello world">Tooltip</p>
2831
```
2932

30-
3 . Including react-tooltip component
33+
3 . Include react-tooltip component
3134

3235

3336
```js
@@ -36,13 +39,13 @@ import ReactTooltip from 'react-tooltip'
3639

3740
**Standalone**
3841

39-
You can import `node_modules/react-tooltip/standalone/react-tooltip.min.js` into your page, please make sure that you have already imported `react` and `react-dom` into your page.
42+
You can import `node_modules/react-tooltip/standalone/react-tooltip.min.js` into your page. Please make sure that you have already imported `react` and `react-dom` into your page.
4043

4144
## Options
4245
Notes:
43-
* The tooltip is using `type: dark` `place: top` `effect: float` as **default** attribute, you don't have to add these options if you don't want to change default
46+
* The tooltip sets `type: dark` `place: top` `effect: float` as **default** attributes. You don't have to add these options if you don't want to change the defaults
4447
* The option you set on `<ReactTooltip />` component will be implemented on every tooltip in a same page: `<ReactTooltip effect="solid" />`
45-
* The option you set on specific element, for example: `<a data-type="warning"></a>` will only make effect on this specific tooltip
48+
* The option you set on a specific element, for example: `<a data-type="warning"></a>` will only affect this specific tooltip
4649

4750
Check example: [React-tooltip Test](http://wwayne.com/react-tooltip)
4851

@@ -75,14 +78,14 @@ className | data-class | String | | extra custom class, can use !importan
7578
Check the example [React-tooltip Test](http://wwayne.com/react-tooltip)
7679

7780
##### Note:
78-
1. **data-tip** is necessary, because `<ReactTooltip />` find tooltip via this attribute
79-
2. **data-for** correspond to the **id** of `<ReactTooltip />`
80-
3. When using react component as tooltip, you can have many `<ReactTooltip />` in a page but they should have different **id**
81+
1. **data-tip** is necessary, because `<ReactTooltip />` finds the tooltip via this attribute
82+
2. **data-for** corresponds to the **id** of `<ReactTooltip />`
83+
3. When using react component as tooltip, you can have many `<ReactTooltip />` in a page but they should have different **id**s
8184

8285
## Static Methods
83-
###ReactTooltip.hide(target)
86+
### ReactTooltip.hide(target)
8487

85-
> Hide the tooltip manually, the target is optional, if no target passed in, all exitent tooltip will be hiden
88+
> Hide the tooltip manually, the target is optional, if no target passed in, all existing tooltips will be hidden
8689
8790
```js
8891
import {findDOMNode} from 'react-dom'
@@ -93,11 +96,11 @@ import ReactTooltip from 'react-tooltip'
9396
<ReactTooltip />
9497
```
9598

96-
###ReactTooltip.rebuild()
99+
### ReactTooltip.rebuild()
97100

98101
> Rebinding all tooltips
99102
100-
###ReactTooltip.show(target)
103+
### ReactTooltip.show(target)
101104

102105
> Show specific tooltip manually, for example:
103106
@@ -110,19 +113,19 @@ import ReactTooltip from 'react-tooltip'
110113
<ReactTooltip />
111114
```
112115

113-
## Trouble Shooting
116+
## Troubleshooting
114117
### 1. Using tooltip within the modal (e.g. [react-modal](https://github.com/reactjs/react-modal))
115-
The component was designed to set a `<Reactooltip />` one place then use tooltip everywhere, but a lot of people stuck in using this component with modal, you can check the discussion [here](https://github.com/wwayne/react-tooltip/issues/130), the summarization of solving the problem is as following:
118+
The component was designed to set `<ReactTooltip />` once and then use tooltip everywhere, but a lot of people get stuck when using this component in a modal. You can read the discussion [here](https://github.com/wwayne/react-tooltip/issues/130). To solve this problem:
116119

117-
1. Put `<ReactTooltip />` out of the `<Modal>`
120+
1. Place `<ReactTooltip />` outside of the `<Modal>`
118121
2. Use `ReactTooltip.rebuild()` when opening the modal
119-
3. If your modal's z-index happens to higher than the tooltip, use the attribute `className` to custom your tooltip's z-index
122+
3. If your modal's z-index happens to be higher than the tooltip's, use the attribute `className` to custom your tooltip's z-index
120123

121-
>I suggest always put `<ReactTooltip />` in the Highest level or smart component of Redux, so you might need these static
124+
>I suggest always putting `<ReactTooltip />` in the Highest level or smart component of Redux, so you might need these static
122125
method to control tooltip's behaviour in some situations
123126

124127
### 2. Hide tooltip when getContent returns undefined
125-
When you set `getContent={() => { return }}` you will find the tooltip will dispaly `true`, that's because React will set the value of data-* to be 'true' automatically if there is no value to be set. So you have to set `data-tip=''` in this situaction.
128+
When you set `getContent={() => { return }}` you will find the tooltip will display `true`. That's because React will set the value of data-* to be 'true' automatically if there is no value to be set. So you have to set `data-tip=''` in this situation.
126129

127130
```jsx
128131
<p data-tip='' data-for='test'></p>
@@ -139,6 +142,9 @@ Same for empty children, if you don't want show the tooltip when the children is
139142
## Article
140143
[How I insert sass into react component](https://medium.com/@wwayne_me/how-i-insert-sass-into-my-npm-react-component-b46b9811c226#.gi4hxu44a)
141144

145+
## Authors
146+
see [AUTHORS](https://github.com/wwayne/react-tooltip/blob/master/AUTHORS.txt)
147+
142148
### License
143149

144150
MIT

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-tooltip",
3-
"version": "3.2.7",
3+
"version": "3.2.9",
44
"description": "react tooltip component",
55
"main": "dist/index.js",
66
"scripts": {

src/index.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ class ReactTooltip extends Component {
8686
this.bind([
8787
'showTooltip',
8888
'updateTooltip',
89+
'checkSameTarget',
8990
'hideTooltip',
9091
'globalRebuild',
9192
'globalShow',
@@ -147,7 +148,8 @@ class ReactTooltip extends Component {
147148
if (!id) {
148149
targetArray = document.querySelectorAll('[data-tip]:not([data-for])')
149150
} else {
150-
targetArray = document.querySelectorAll(`[data-tip][data-for="${id}"]`)
151+
const escaped = id.replace(/\\/g, '\\\\').replace(/"/g, '\\"')
152+
targetArray = document.querySelectorAll(`[data-tip][data-for="${escaped}"]`)
151153
}
152154
// targetArray is a NodeList, convert it to a real array
153155
return nodeListToArray(targetArray)
@@ -179,6 +181,7 @@ class ReactTooltip extends Component {
179181
target.addEventListener('mousemove', this.updateTooltip, isCaptureMode)
180182
}
181183
target.addEventListener('mouseleave', this.hideTooltip, isCaptureMode)
184+
target.addEventListener('DOMNodeRemovedFromDocument', this.checkSameTarget, isCaptureMode)
182185
})
183186

184187
// Global event to hide tooltip
@@ -212,6 +215,7 @@ class ReactTooltip extends Component {
212215
target.removeEventListener('mouseenter', this.showTooltip, isCaptureMode)
213216
target.removeEventListener('mousemove', this.updateTooltip, isCaptureMode)
214217
target.removeEventListener('mouseleave', this.hideTooltip, isCaptureMode)
218+
target.removeEventListener('DOMNodeRemovedFromDocument', this.checkSameTarget, isCaptureMode)
215219
}
216220

217221
/**
@@ -328,6 +332,12 @@ class ReactTooltip extends Component {
328332
}
329333
}
330334

335+
checkSameTarget (e) {
336+
if (this.state.currentTarget === e.currentTarget) {
337+
this.hideTooltip(e)
338+
}
339+
}
340+
331341
/**
332342
* When mouse leave, hide tooltip
333343
*/
@@ -438,15 +448,15 @@ class ReactTooltip extends Component {
438448
if (html) {
439449
return (
440450
<Wrapper className={`${tooltipClass} ${extraClass}`}
441-
{...ariaProps}
442-
data-id='tooltip'
443-
dangerouslySetInnerHTML={{__html: placeholder}}/>
451+
{...ariaProps}
452+
data-id='tooltip'
453+
dangerouslySetInnerHTML={{__html: placeholder}}/>
444454
)
445455
} else {
446456
return (
447457
<Wrapper className={`${tooltipClass} ${extraClass}`}
448-
{...ariaProps}
449-
data-id='tooltip'>{placeholder}</Wrapper>
458+
{...ariaProps}
459+
data-id='tooltip'>{placeholder}</Wrapper>
450460
)
451461
}
452462
}

standalone/react-tooltip.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,8 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
490490
if (!id) {
491491
targetArray = document.querySelectorAll('[data-tip]:not([data-for])');
492492
} else {
493-
targetArray = document.querySelectorAll('[data-tip][data-for="' + id + '"]');
493+
var escaped = id.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
494+
targetArray = document.querySelectorAll('[data-tip][data-for="' + escaped + '"]');
494495
}
495496
// targetArray is a NodeList, convert it to a real array
496497
return (0, _nodeListToArray2.default)(targetArray);

standalone/react-tooltip.min.js

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

0 commit comments

Comments
 (0)