File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed
Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -78,6 +78,7 @@ class p5 {
7878 this . _updateWindowSize ( ) ;
7979
8080 // Apply addon defined decorations
81+ p5 . prototype . __originalMethods = p5 . prototype . __originalMethods || { } ;
8182 for ( const [ patternArray , decoration ] of p5 . decorations ) {
8283 for ( const member in p5 . prototype ) {
8384 // Member must be a function
@@ -91,7 +92,10 @@ class p5 {
9192 }
9293 } ) ) continue ;
9394
94- const copy = p5 . prototype [ member ] . bind ( this ) ;
95+ // Store a copy of the original, unbound prototype method so that if we make a new p5 instance
96+ // later, we don't double-, triple-, etc bind the function
97+ p5 . prototype . __originalMethods [ member ] = p5 . prototype . __originalMethods [ member ] || p5 . prototype [ member ] ;
98+ const copy = p5 . prototype . __originalMethods [ member ] . bind ( this ) ;
9599 p5 . prototype [ member ] = decoration . call ( this , copy , member ) ;
96100 }
97101 }
You can’t perform that action at this time.
0 commit comments