File tree Expand file tree Collapse file tree 4 files changed +45
-2
lines changed Expand file tree Collapse file tree 4 files changed +45
-2
lines changed Original file line number Diff line number Diff line change @@ -348,7 +348,7 @@ function fesCore(p5, fn){
348
348
// actual name with correct capitalization doesnt exist in context,
349
349
// and if the user-defined symbol is of the type function
350
350
if (
351
- fxns [ lowercase ] &&
351
+ fxns . hasOwnProperty ( lowercase ) &&
352
352
! context [ fxns [ lowercase ] ] &&
353
353
typeof context [ prop ] === 'function'
354
354
) {
Original file line number Diff line number Diff line change @@ -137,10 +137,11 @@ class p5 {
137
137
bindGlobal ( p ) ;
138
138
}
139
139
140
+ const protectedProperties = [ 'constructor' , 'length' , 'print' ] ;
140
141
// Attach its properties to the window
141
142
for ( const p in this ) {
142
143
if ( this . hasOwnProperty ( p ) ) {
143
- if ( p [ 0 ] === '_' ) continue ;
144
+ if ( p [ 0 ] === '_' || protectedProperties . includes ( p ) ) continue ;
144
145
bindGlobal ( p ) ;
145
146
}
146
147
}
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html >
3
+ < head >
4
+ < script src ="/lib/p5.js "> </ script >
5
+ </ head >
6
+ < body >
7
+ < script >
8
+ new p5 ( ) ;
9
+ </ script >
10
+ </ body >
11
+ </ html >
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html >
3
+ < head >
4
+ < script src ="lib/p5.js "> </ script >
5
+ </ head >
6
+ < body >
7
+ < script >
8
+ // Instance mode test
9
+ new p5 ( ( p ) => {
10
+ p . setup = function ( ) {
11
+ p . createCanvas ( 400 , 400 ) ;
12
+ console . log ( "Instance mode setup called" ) ;
13
+ }
14
+
15
+ // Intentionally miscapitalized function to test error detection
16
+ p . mousePressed = function ( ) {
17
+ console . log ( "correct capitalization" ) ;
18
+ }
19
+
20
+ p . MousePressed = function ( ) {
21
+ console . log ( "wrong capitalization" ) ;
22
+ }
23
+
24
+ // Test constructor-related behavior
25
+ p . Constructor = function ( ) {
26
+ console . log ( "shouldn't trigger error" ) ;
27
+ }
28
+ } ) ;
29
+ </ script >
30
+ </ body >
31
+ </ html >
You can’t perform that action at this time.
0 commit comments