Skip to content

Commit d16d389

Browse files
committed
refactor: Don't calculate random attr every time
1 parent 4e08b60 commit d16d389

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/bindnode/_selectnodes.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import toArray from '../_helpers/toarray';
33
import dom from '../_dom';
44

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

78
// the function selects nodes based on a selector (including custom values, eg :sandbox)
89
// TODO: selectNodes looks not good, it needs to be refactored and accelerated if possible
@@ -34,8 +35,6 @@ export default function selectNodes(object, givenSelector) {
3435
if (subSelector.indexOf('>') === 0) {
3536
// selecting children
3637
nofn.forEach(boundNodes, (node) => {
37-
const randomAttr = `m${Math.random()}`.replace('.', '');
38-
3938
node.setAttribute(randomAttr, randomAttr);
4039
const selected = node.querySelectorAll(
4140
`[${randomAttr}="${randomAttr}"] ${subSelector}`

0 commit comments

Comments
 (0)