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'
1515import getPosition from './utils/getPosition'
1616import getTipContent from './utils/getTipContent'
1717import { parseAria } from './utils/aria'
18-
19- import createArrayFromMixed from 'fbjs/lib/createArrayFromMixed'
18+ import nodeListToArray from './utils/nodeListToArray'
2019
2120/* CSS */
2221import cssStyle from './style'
@@ -148,15 +147,13 @@ class ReactTooltip extends Component {
148147 */
149148 getTargetArray ( id ) {
150149 let targetArray
151-
152150 if ( ! id ) {
153151 targetArray = document . querySelectorAll ( '[data-tip]:not([data-for])' )
154152 } else {
155153 targetArray = document . querySelectorAll ( `[data-tip][data-for="${ id } "]` )
156154 }
157-
158155 // targetArray is a NodeList, convert it to a real array
159- return createArrayFromMixed ( targetArray )
156+ return nodeListToArray ( targetArray )
160157 }
161158
162159 /**
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