()
| 1159 | |
| 1160 | _image; |
| 1161 | async loadImage() { |
| 1162 | if (this._image !== undefined) return; |
| 1163 | |
| 1164 | this._image = null; |
| 1165 | |
| 1166 | let blob; |
| 1167 | switch (this.tagName) { |
| 1168 | case 'img': { |
| 1169 | const res = await this.document.page.fetch(this.attrs.src); |
| 1170 | const type = res.headers.get('Content-Type'); |
| 1171 | const data = await res.arrayBuffer(); |
| 1172 | |
| 1173 | blob = new Blob([ new Uint8Array(data) ], { type }); |
| 1174 | break; |
| 1175 | } |
| 1176 | |
| 1177 | // hack: load svg from content |
| 1178 | case 'svg': { |
| 1179 | const svg = this.serialize(false); |
| 1180 | this.children = []; |
| 1181 | |
| 1182 | console.log(svg); |
| 1183 | |
| 1184 | blob = new Blob([ svg ], { type: 'image/svg+xml' }); |
| 1185 | break; |
| 1186 | } |
| 1187 | } |
| 1188 | |
| 1189 | const image = new Image(); |
| 1190 | image.src = URL.createObjectURL(blob); |
| 1191 | |
| 1192 | image.style.display = 'none'; |
| 1193 | document.body.appendChild(image); |
| 1194 | |
| 1195 | image.onload = () => { |
| 1196 | this._image = image; |
| 1197 | this.invalidateCaches(); |
| 1198 | }; |
| 1199 | } |
| 1200 | |
| 1201 | marginTop() { |
| 1202 | return this.lengthAbs(this.css()['margin-top'], 'margin-top'); |
no test coverage detected