From aafd0eb638a5aeabc9883c6f5ed50699b1524665 Mon Sep 17 00:00:00 2001 From: maciejmatu Date: Mon, 9 Oct 2023 16:40:25 +0200 Subject: [PATCH 1/3] Fix updating image before initial image is loaded or the loading failed --- src/source/image_source.js | 2 +- test/unit/source/image_source.test.js | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/source/image_source.js b/src/source/image_source.js index be6dc961a3d..03572710118 100644 --- a/src/source/image_source.js +++ b/src/source/image_source.js @@ -227,7 +227,7 @@ class ImageSource extends Evented implements Source { * }); */ updateImage(options: {url: string, coordinates?: Coordinates}): this { - if (!this.image || !options.url) { + if (!options.url) { return this; } if (this._imageRequest && options.url !== this.options.url) { diff --git a/test/unit/source/image_source.test.js b/test/unit/source/image_source.test.js index e6bb11bfebc..cb554dd88c5 100644 --- a/test/unit/source/image_source.test.js +++ b/test/unit/source/image_source.test.js @@ -55,6 +55,12 @@ test('ImageSource', (t) => { img.onload(); img.data = new Uint8Array(req.response); }; + const respondNotFound = () => { + const req = requests.shift(); + req.setStatus(404); + req.onerror(); + req.response = new ArrayBuffer(1); + }; t.stub(browser, 'getImageData').callsFake(() => new ArrayBuffer(1)); t.test('constructor', (t) => { @@ -256,5 +262,22 @@ test('ImageSource', (t) => { t.end(); }); + t.test('updates image before first image was loaded', (t) => { + const source = createSource({url : '/notfound.png'}); + const map = new StubMap(); + const spy = t.spy(map._requestManager, 'transformRequest'); + const errorStub = t.stub(console, 'error'); + source.onAdd(map); + respondNotFound(); + t.ok(errorStub.calledOnce); + t.notOk(source.image); + source.updateImage({url: '/image2.png'}); + respond(); + t.ok(spy.calledTwice); + t.equal(spy.getCall(1).args[0], '/image2.png'); + t.equal(spy.getCall(1).args[1], 'Image'); + t.end(); + }); + t.end(); }); From f1a4f46afef5e1b68e1ea43e99991a98d2deed34 Mon Sep 17 00:00:00 2001 From: maciejmatu Date: Thu, 30 Nov 2023 23:58:18 +0100 Subject: [PATCH 2/3] CI trigger From 2ca0721a710bff6166e7318bdb45e7efb9dd69c8 Mon Sep 17 00:00:00 2001 From: maciejmatu Date: Fri, 1 Dec 2023 01:28:09 +0100 Subject: [PATCH 3/3] CI trigger