[javascript mode] Fix context tracking for comma-separated bodies

Closes #2000