Skip to content

Commit

Permalink
fix(selector): lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
omerdn1 committed Oct 28, 2019
1 parent 99be4d1 commit 873c2a8
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,24 +186,22 @@ class ReactTooltip extends React.Component {
* Pick out corresponded target elements
*/
getTargetArray (id) {
let targetArray = [];
let selector;
let targetArray = []
let selector
if (!id) {
selector = '[data-tip]:not([data-for])';
selector = '[data-tip]:not([data-for])'
} else {
const escaped = id.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
selector = '[data-tip][data-for="' + escaped + '"]';
const escaped = id.replace(/\\/g, '\\\\').replace(/"/g, '\\"')
selector = '[data-tip][data-for="' + escaped + '"]'
}

// Scan document for shadow DOM elements
nodeListToArray(document.getElementsByTagName('*'))
.filter(element => element.shadowRoot)
.forEach(element => {
targetArray = targetArray.concat(nodeListToArray(element.shadowRoot.querySelectorAll(selector)));
});

targetArray = targetArray.concat(nodeListToArray(document.querySelectorAll(selector)));

targetArray = targetArray.concat(nodeListToArray(element.shadowRoot.querySelectorAll(selector)))
})
targetArray = targetArray.concat(nodeListToArray(document.querySelectorAll(selector)))
return targetArray
}

Expand Down

0 comments on commit 873c2a8

Please sign in to comment.