1 | const HTMLElement = require('./HTMLElement');
|
2 | const Image = require('./Image');
|
3 |
|
4 | module.exports = function ImageFactory(document, ...size) {
|
5 | const [width, height] = size;
|
6 | let img = document.createElement('img');
|
7 | if (img.constructor === HTMLElement)
|
8 | img = new Image(document);
|
9 | switch (size.length) {
|
10 | case 1:
|
11 | img.width = width;
|
12 | img.height = width;
|
13 | return img;
|
14 | case 2:
|
15 | img.width = width;
|
16 | img.height = height;
|
17 | return img;
|
18 | }
|
19 | return img;
|
20 | };
|