Khan / Khan/live-editor

Parser error with certain objects in top level variables in Chrome

Open
#423 8 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
776
Forks
180
PR merge metrics
No merged PRs in 30d

Description

I'm not entirely sure if this is meant as a security feature or not, but if you try to put references to `window` or the global program context into top level variables you get an elusive "Parser error" which happens only if you are using Chrome **and** have _any_ PJS callback function defined anywhere in your program.
[This program](https://www.khanacademy.org/computer-programming/parser-error-in-chrome/6537414473547776) demonstrates the problem. If you remove the draw function or use Firefox it works. You can change the `win` definition to

```
var pjs = function() {return this;};
pjs = pjs();
```

if you want to see the same problem with the program context instead of `window`.

So far, I have been unable to find the source of this bug.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the linked Khan Academy reproduction and compare Chrome with Firefox. Reproduce the parser error with a top-level reference to window or the program context and a PJS callback, then trace the parser or execution path responsible. Done means the example runs in Chrome without the parser error while preserving the callback behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.