(newImageOrSrc, image, hostEl, onload, cbPayload)
| 8306 | } |
| 8307 | } |
| 8308 | function createOrUpdateImage(newImageOrSrc, image, hostEl, onload, cbPayload) { |
| 8309 | if (!newImageOrSrc) { |
| 8310 | return image; |
| 8311 | } |
| 8312 | else if (typeof newImageOrSrc === 'string') { |
| 8313 | if ((image && image.__zrImageSrc === newImageOrSrc) || !hostEl) { |
| 8314 | return image; |
| 8315 | } |
| 8316 | var cachedImgObj = globalImageCache.get(newImageOrSrc); |
| 8317 | var pendingWrap = { hostEl: hostEl, cb: onload, cbPayload: cbPayload }; |
| 8318 | if (cachedImgObj) { |
| 8319 | image = cachedImgObj.image; |
| 8320 | !isImageReady(image) && cachedImgObj.pending.push(pendingWrap); |
| 8321 | } |
| 8322 | else { |
| 8323 | image = new Image(); |
| 8324 | image.onload = image.onerror = imageOnLoad; |
| 8325 | globalImageCache.put(newImageOrSrc, image.__cachedImgObj = { |
| 8326 | image: image, |
| 8327 | pending: [pendingWrap] |
| 8328 | }); |
| 8329 | image.src = image.__zrImageSrc = newImageOrSrc; |
| 8330 | } |
| 8331 | return image; |
| 8332 | } |
| 8333 | else { |
| 8334 | return newImageOrSrc; |
| 8335 | } |
| 8336 | } |
| 8337 | function imageOnLoad() { |
| 8338 | var cachedImgObj = this.__cachedImgObj; |
| 8339 | this.onload = this.onerror = this.__cachedImgObj = null; |
no test coverage detected
searching dependent graphs…