Support passing canvas ids straight to View constructor.

This commit is contained in:
Jürg Lehni 2011-08-01 16:18:17 +01:00
parent 6b3fdb0880
commit 9195f026d7

View file

@ -35,7 +35,9 @@ var View = this.View = Base.extend(/** @lends View# */{
this._index = this._scope.views.push(this) - 1;
// Handle canvas argument
var size;
if (canvas && canvas instanceof HTMLCanvasElement) {
if (typeof canvas === 'string')
canvas = document.getElementById(canvas);
if (canvas instanceof HTMLCanvasElement) {
this._canvas = canvas;
// If the canvas has the resize attribute, resize the it to fill the
// window and resize it again whenever the user resizes the window.