Matter-js: Renderer warns about options.element when canvas is explicitely specified

Created on 19 Apr 2017  路  4Comments  路  Source: liabru/matter-js

When I create a new Renderer by specifying the canvas property and leaving the element property empty, I get a warning saying:

Matter.js: Render.create: options.element was undefined, render.canvas was created but not appended

As far as I'm concerned, I do not see why we would specify element if we are already telling it the canvas to use.

investigate task

Most helpful comment

As far as I can tell, this has been fixed in edge release (0.14.1). Therefore, I'm going to close this issue. Thanks!

All 4 comments

Looking at the code, it always prints if no element is provided. Also, if you have canvas AND element, it will be moved from it's original location to a child of the element (perhaps this is desired?).

The simple fix is to have a flag if render.canvas was provided and don't log if it was - but perhaps the "element" and "canvas" could be merged into just "element". If element is a canvas element, it is used in place - otherwise a new canvas is created and appended as a child of element. Though then this would be an API change.

but perhaps the "element" and "canvas" could be merged into just "element". If element is a canvas element, it is used in place - otherwise a new canvas is created and appended as a child of element. Though then this would be an API change.

This makes sense!

I think the error message was in there because some people were confused, but maybe I should review this if I can think of a way to avoid any breaking API change.

As far as I can tell, this has been fixed in edge release (0.14.1). Therefore, I'm going to close this issue. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jack-guy picture jack-guy  路  3Comments

maximilianberndt picture maximilianberndt  路  4Comments

koko236 picture koko236  路  3Comments

BlueInt32 picture BlueInt32  路  4Comments

liabru picture liabru  路  3Comments