Skip to content

Commit eac15d9

Browse files
authored
Merge pull request #7765 from HughJacks/fix-fes-error
Fixed Error in FES prevents message from being shown, Prevented 'window' properties from being overwritten
2 parents 4ca88f3 + a5f0be6 commit eac15d9

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/core/friendly_errors/fes_core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ function fesCore(p5, fn){
348348
// actual name with correct capitalization doesnt exist in context,
349349
// and if the user-defined symbol is of the type function
350350
if (
351-
fxns[lowercase] &&
351+
fxns.hasOwnProperty(lowercase) &&
352352
!context[fxns[lowercase]] &&
353353
typeof context[prop] === 'function'
354354
) {

src/core/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,11 @@ class p5 {
137137
bindGlobal(p);
138138
}
139139

140+
const protectedProperties = ['constructor', 'length'];
140141
// Attach its properties to the window
141142
for (const p in this) {
142143
if (this.hasOwnProperty(p)) {
143-
if(p[0] === '_') continue;
144+
if(p[0] === '_' || protectedProperties.includes(p)) continue;
144145
bindGlobal(p);
145146
}
146147
}

0 commit comments

Comments
 (0)