Skip to content

Commit df267cb

Browse files
committed
[LazyImage] Renaming JavaScript event key
1 parent 10461ed commit df267cb

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

src/LazyImage/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@
77
for more details.
88
- The `data-hd-src` attribute was changed to use a Stimulus value called `src`. See the
99
updated README for usage.
10+
- For both JavaScript events - `lazy-image:connect` and `lazy-image:ready` -
11+
the `event.detail.hd` `Image` instance was moved to `event.detail.image`.
1012
- Support added for Symfony 6

src/LazyImage/Resources/assets/dist/controller.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ class default_1 extends Controller {
99
if (srcsetString) {
1010
this.element.srcset = srcsetString;
1111
}
12-
this._dispatchEvent('lazy-image:ready', { hd });
12+
this._dispatchEvent('lazy-image:ready', { image: hd });
1313
});
1414
hd.src = this.srcValue;
1515
if (srcsetString) {
1616
hd.srcset = srcsetString;
1717
}
18-
this._dispatchEvent('lazy-image:connect', { hd });
18+
this._dispatchEvent('lazy-image:connect', { image: hd });
1919
}
2020
_calculateSrcsetString() {
2121
if (!this.hasSrcsetValue) {

src/LazyImage/Resources/assets/src/controller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ export default class extends Controller {
2727
if (srcsetString) {
2828
this.element.srcset = srcsetString;
2929
}
30-
this._dispatchEvent('lazy-image:ready', { hd });
30+
this._dispatchEvent('lazy-image:ready', { image: hd });
3131
});
3232

3333
hd.src = this.srcValue;
3434
if (srcsetString) {
3535
hd.srcset = srcsetString;
3636
}
3737

38-
this._dispatchEvent('lazy-image:connect', { hd });
38+
this._dispatchEvent('lazy-image:connect', { image: hd });
3939
}
4040

4141
_calculateSrcsetString(): string {

src/LazyImage/Resources/assets/test/controller.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class CheckController extends Controller {
2020
this.element.addEventListener('lazy-image:connect', (event) => {
2121
// the Image won't natively have its "load" method in this test
2222
// so we trigger it manually, to "fake" the Image loading.
23-
event.detail.hd.dispatchEvent(new Event('load'));
23+
event.detail.image.dispatchEvent(new Event('load'));
2424
this.element.classList.add('connected');
2525
});
2626
}

0 commit comments

Comments
 (0)