Skip to content

Commit 2ff3c86

Browse files
committed
fix: loop protect breaking when no LOC
1 parent 357f74a commit 2ff3c86

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

lib/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ const generateInside = ({ t, id, line, ch, timeout, extra } = {}) => {
3838
};
3939

4040
const protect = (t, timeout, extra) => path => {
41+
if (!path.node.loc) {
42+
// I don't really know _how_ we get into this state
43+
// but https://jsbin.com/mipesawapi/1/ triggers it
44+
// and the node, I'm guessing after translation,
45+
// doesn't have a line in the code, so this blows up.
46+
return;
47+
}
4148
const id = path.scope.generateUidIdentifier('LP');
4249
const before = generateBefore(t, id);
4350
const inside = generateInside({

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"name": "loop-protect",
44
"description": "Prevent infinite loops in dynamically eval'd JavaScript.",
55
"main": "dist/",
6-
"version": "2.1.5",
6+
"version": "2.1.6",
77
"homepage": "https://github.com/jsbin/loop-protect",
88
"repository": {
99
"type": "git",

0 commit comments

Comments
 (0)