18 lines
432 B
JavaScript
18 lines
432 B
JavaScript
'use strict';
|
|
|
|
module.exports = function(element) {
|
|
if (element instanceof HTMLCanvasElement) {
|
|
this.canvas = element;
|
|
|
|
} else if (typeof element === 'string') {
|
|
this.canvas = document.querySelector(element);
|
|
|
|
} else {
|
|
throw new Error('The element you used is neither a String, nor a HTMLCanvasElement');
|
|
}
|
|
|
|
if (!this.canvas) {
|
|
throw new Error('`' + element + '` could not be found in the DOM');
|
|
}
|
|
};
|