Decouple LevelRender from window.document
parent
2240a61ac2
commit
3b1ac2c78c
|
@ -151,6 +151,7 @@ module.exports = Class( 'LevelRender',
|
||||||
'private _getObjCanvas': function()
|
'private _getObjCanvas': function()
|
||||||
{
|
{
|
||||||
const canvas = this._ctx.canvas,
|
const canvas = this._ctx.canvas,
|
||||||
|
document = this._getDocument( canvas ),
|
||||||
canvas_obj = document.createElement( 'canvas' );
|
canvas_obj = document.createElement( 'canvas' );
|
||||||
|
|
||||||
// mimic the dimensions and positions of the original canvas
|
// mimic the dimensions and positions of the original canvas
|
||||||
|
@ -167,6 +168,25 @@ module.exports = Class( 'LevelRender',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get HTMLDocument node from element ELEMENT
|
||||||
|
*
|
||||||
|
* ELEMENT must be on a DOM. This allows us to always reference the
|
||||||
|
* proper document node without being coupled with the browser's
|
||||||
|
* window.document, which may not be what we're interested in.
|
||||||
|
*
|
||||||
|
* @param {HTMLElement} element reference element
|
||||||
|
*
|
||||||
|
* @return {HTMLDocument} document node
|
||||||
|
*/
|
||||||
|
'private _getDocument': function( element )
|
||||||
|
{
|
||||||
|
return ( element.parentElement === null )
|
||||||
|
? element.parentNode
|
||||||
|
: this._getDocument( element.parentElement );
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render the provided level
|
* Render the provided level
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue