Open twavv opened 5 years ago
I think there's definitely some merit to such a change - although there are plenty of instances where we're using document
elsewhere in the library that might also need similar checking?
This seems helpful in a general case too because it would prevent us walking over all canvases on the page that don't belong to us and hiding them all. (Use case of multiple p5 sketches, or just being included alongside other canvas elements)
In particular, perhaps after this part of the code: https://github.com/processing/p5.js/blob/edb41cf513efafd3734221a3b8cdc266f90d6bb3/src/core/main.js#L235-L240
I think we could add
this._userNode = this._userNode || document;
and then use this._userNode
more often throughout the code-base.
could we use the p5.prototype._elements
array for this?
This is causing some issues in a project where we use IFrames and share some libraries between them (explicitly, https://github.com/JuliaGizmos/WebIO.jl/issues/225 is where I lay out the issues we're facing).
Essentially, I'd like to change this line https://github.com/processing/p5.js/blob/edb41cf513efafd3734221a3b8cdc266f90d6bb3/src/core/main.js#L342 to be something more like
I can open up a PR if you'd accept it but I wanted to hear back first.