File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -15,8 +15,7 @@ import getEffect from './decorators/getEffect'
15
15
import getPosition from './utils/getPosition'
16
16
import getTipContent from './utils/getTipContent'
17
17
import { parseAria } from './utils/aria'
18
-
19
- import createArrayFromMixed from 'fbjs/lib/createArrayFromMixed'
18
+ import nodeListToArray from './utils/nodeListToArray'
20
19
21
20
/* CSS */
22
21
import cssStyle from './style'
@@ -148,15 +147,13 @@ class ReactTooltip extends Component {
148
147
*/
149
148
getTargetArray ( id ) {
150
149
let targetArray
151
-
152
150
if ( ! id ) {
153
151
targetArray = document . querySelectorAll ( '[data-tip]:not([data-for])' )
154
152
} else {
155
153
targetArray = document . querySelectorAll ( `[data-tip][data-for="${ id } "]` )
156
154
}
157
-
158
155
// targetArray is a NodeList, convert it to a real array
159
- return createArrayFromMixed ( targetArray )
156
+ return nodeListToArray ( targetArray )
160
157
}
161
158
162
159
/**
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Convert nodelist to array
3
+ * @see https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/core/createArrayFromMixed.js#L24
4
+ * NodeLists are functions in Safari
5
+ */
6
+
7
+ export default function ( nodeList ) {
8
+ const length = nodeList . length
9
+ if ( nodeList . hasOwnProperty ) {
10
+ return Array . prototype . slice . call ( nodeList )
11
+ }
12
+ return new Array ( length ) . fill ( ) . map ( index => nodeList [ index ] )
13
+ }
You can’t perform that action at this time.
0 commit comments