Opened 6 years ago
Closed 6 years ago
#44371 closed defect (bug) (fixed)
Make sure all JS globals are explicitly assigned to the window.
Reported by: | omarreiss | Owned by: | omarreiss |
---|---|---|---|
Milestone: | 5.1 | Priority: | normal |
Severity: | normal | Version: | |
Component: | General | Keywords: | |
Focuses: | javascript | Cc: |
Description
Currently there are a lot of variables in the JavaScript that are being defined in the global scope without being explicitly assigned to the window
. When we start using Webpack to build all the JavaScript, the code will get encapsulated in an anonymous function and those implicit globals could get assigned to a different scope. To make sure that doesn't happen, I've created a patch to make sure all globals are explicitly assigned to the window
.
Attachments (4)
Change History (18)
This ticket was mentioned in Slack in #core-js by adamsilverstein. View the logs.
6 years ago
This ticket was mentioned in Slack in #core-js by aduth. View the logs.
6 years ago
#5
@
6 years ago
- Keywords commit added; needs-testing removed
- Owner set to omarreiss
- Status changed from new to assigned
#6
@
6 years ago
Patch updated, went through everything again, found one more implicit global. Plan on committing this today.
#9
@
6 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
[43577] broke quicktags.js. Also some of the changes there doesn't seem to make much sense, especially for a very very VERY old lib like QuickTags :)
This ticket was mentioned in Slack in #core-js by adamsilverstein. View the logs.
6 years ago
#12
follow-up:
↓ 13
@
6 years ago
- Keywords close added; has-patch commit removed
- Milestone changed from 5.0 to 5.1
@azaozz: Was [43579] the only change that needed to happen here?
#13
in reply to:
↑ 12
@
6 years ago
Replying to pento:
@azaozz: Was [43579] the only change that needed to happen here?
Yeah, assigning of the functions to vars in [43577] broke the order in quicktags.js a bit. The rest seems to be working.
Example (paste in the console):
test(); function test() { console.log(1); } // 1 window.test2(); window.test2 = function() { console.log(2); } // ReferenceError: test2 is not defined.
Let's get this in.
All of these globals appear to be intended to be globally scoped: they're all declared outside the functions where they're used later in the files.