Skip to content

Commit 6897dda

Browse files
committed
model that this in $().each(callback) is a DOM-node
1 parent 8de8696 commit 6897dda

File tree

1 file changed

+8
-0
lines changed
  • javascript/ql/src/semmle/javascript

1 file changed

+8
-0
lines changed

javascript/ql/src/semmle/javascript/DOM.qll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,14 @@ module DOM {
305305
call.getNumArgument() = 1 and
306306
forex(InferredType t | t = call.getArgument(0).analyze().getAType() | t = TTNumber())
307307
)
308+
or
309+
// A `this` node from a callback given to a `$().each(callback)` call.
310+
exists(DataFlow::MethodCallNode eachCall |
311+
eachCall.getMethodName() = "each" and
312+
eachCall.getReceiver().getALocalSource() = JQuery::objectRef() // purposely not using JQuery::MethodCall to avoid `jquery.each()`.
313+
|
314+
this = DataFlow::thisNode(eachCall.getCallback(0).getFunction())
315+
)
308316
}
309317
}
310318
}

0 commit comments

Comments
 (0)