p5.js
p5.js copied to clipboard
Remove superfluous _setProperty method from p5.Element
Topic
I've been looking through the p5.js source code to get a better understanding of it and to get some ideas for a p5 library I'm working on.
I noticed that there are several places where a p5.Element _setProperty method is being called. All this method does is use string key syntax to set the value of an arbitrary property.
Is there some reason this method exists that I'm not seeing? Can it be removed to cut down on the indirection?
Welcome! 👋 Thanks for opening your first issue here! And to ensure the community is able to respond to your issue, please make sure to fill out the inputs in the issue forms. Thank you!
_setProperty is used so properly handle both global mode and instance mode, ie. in instance mode we can just set the property value on the instance object but in global mode we need to set the property value on the global window object as well. The _setProperty method takes care of this check and conditional value setting to simplify the rest of the codebase.