Skip to content

Commit

Permalink
refactor: Don't calculate random attr every time
Browse files Browse the repository at this point in the history
  • Loading branch information
finom committed Nov 1, 2016
1 parent 4e08b60 commit d16d389
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/bindnode/_selectnodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import toArray from '../_helpers/toarray';
import dom from '../_dom';

const customSelectorReg = /\s*:bound\(([^(]*)\)\s*([\S\s]*)\s*|\s*:sandbox\s*([\S\s]*)\s*/;
const randomAttr = `${Math.random().toString().replace('0.', 'x')}y`; // x12345y

// the function selects nodes based on a selector (including custom values, eg :sandbox)
// TODO: selectNodes looks not good, it needs to be refactored and accelerated if possible
Expand Down Expand Up @@ -34,8 +35,6 @@ export default function selectNodes(object, givenSelector) {
if (subSelector.indexOf('>') === 0) {
// selecting children
nofn.forEach(boundNodes, (node) => {
const randomAttr = `m${Math.random()}`.replace('.', '');

node.setAttribute(randomAttr, randomAttr);
const selected = node.querySelectorAll(
`[${randomAttr}="${randomAttr}"] ${subSelector}`
Expand Down

0 comments on commit d16d389

Please sign in to comment.