From 0e16ab515cb191a6adfc4e9210c1f0b0b9fa4677 Mon Sep 17 00:00:00 2001 From: Logan Tegman Date: Wed, 6 Jan 2016 11:27:03 -0800 Subject: [PATCH] Fix loop protect thinking default cases are loop labels --- gulpfile.js | 2 +- public/js/lib/loop-protect/loop-protect.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index a8e0329ca2..a73cab824b 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -521,7 +521,7 @@ gulp.task('reload', function() { gulp.task('watch', watchDependents, function() { gulp.watch(paths.lessFiles, ['less']); - gulp.watch(paths.js, ['js']); + gulp.watch(paths.js.concat(paths.vendorChallenges), ['js']); gulp.watch(paths.challenges, ['test-challenges', 'reload']); gulp.watch(paths.js, ['js', 'dependents']); gulp.watch( diff --git a/public/js/lib/loop-protect/loop-protect.js b/public/js/lib/loop-protect/loop-protect.js index ac3376b6e1..60031599f5 100644 --- a/public/js/lib/loop-protect/loop-protect.js +++ b/public/js/lib/loop-protect/loop-protect.js @@ -18,7 +18,7 @@ if (typeof DEBUG === 'undefined') { DEBUG = true; } // the standard loops - note that recursive is not supported var re = /\b(for|while|do)\b/g; var reSingle = /\b(for|while|do)\b/; - var labelRe = /\b([a-z_]{1}\w+:)/i; + var labelRe = /\b(?!default:)([a-z_]{1}\w+:)/i; var comments = /(?:\/\*(?:[\s\S]*?)\*\/)|(?:([\s;])+\/\/(?:.*)$)/gm; var loopTimeout = 1000; @@ -136,7 +136,7 @@ if (typeof DEBUG === 'undefined') { DEBUG = true; } // so that we insert in to the correct location (instead of possibly // outside the logic return line.slice(0, matchPosition) + ';' + method + '({ line: ' + lineNum + ', reset: true }); ' + line.slice(matchPosition); - }; + } if (!offset) { offset = 0;