svelte-remote-image 0.2.3 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,7 +24,7 @@ $: {
24
24
  }
25
25
  afterUpdate(async () => {
26
26
  const img = getImgElement();
27
- if (!img) {
27
+ if (!img || !img.complete) {
28
28
  return;
29
29
  }
30
30
  if (img.naturalWidth !== 0 && img.naturalHeight !== 0) {
@@ -38,6 +38,9 @@ const handleImgError = (e) => {
38
38
  if (e && e.type !== "error") {
39
39
  return;
40
40
  }
41
+ if (!src.failback) {
42
+ return;
43
+ }
41
44
  const img = getImgElement();
42
45
  if (!img) {
43
46
  return;
@@ -55,17 +58,7 @@ const handleImgError = (e) => {
55
58
  if (!failbackUrl) {
56
59
  return;
57
60
  }
58
- src = {
59
- ...src,
60
- img: failbackUrl,
61
- webp: [],
62
- jpeg: [],
63
- png: [],
64
- placeholder: {
65
- color: src.placeholder?.color,
66
- dataUri: src.placeholder?.dataUri
67
- }
68
- };
61
+ img.src = failbackUrl;
69
62
  };
70
63
  const handleLoaded = (e) => {
71
64
  const img = e.currentTarget;
@@ -4,8 +4,8 @@ declare const __propDef: {
4
4
  props: {
5
5
  src: ImageSrc;
6
6
  style?: string | undefined;
7
- alt?: "" | undefined;
8
- title?: "" | undefined;
7
+ alt?: string | undefined;
8
+ title?: string | undefined;
9
9
  };
10
10
  events: {
11
11
  [evt: string]: CustomEvent<any>;
@@ -18,7 +18,7 @@ export type ImageProps = typeof __propDef.props;
18
18
  export type ImageEvents = typeof __propDef.events;
19
19
  export type ImageSlots = typeof __propDef.slots;
20
20
  export default class Image extends SvelteComponent<ImageProps, ImageEvents, ImageSlots> {
21
- get alt(): "";
22
- get title(): "";
21
+ get alt(): string;
22
+ get title(): string;
23
23
  }
24
24
  export {};
@@ -9,7 +9,7 @@ export interface ImageSrc {
9
9
  webp?: Srcset[];
10
10
  jpeg?: Srcset[];
11
11
  png?: Srcset[];
12
- failback: string[];
12
+ failback?: string[];
13
13
  placeholder?: {
14
14
  dataUri?: string;
15
15
  color?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-remote-image",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "license": "MIT",
5
5
  "homepage": "https://github.com/ocknamo/svelte-remote-image",
6
6
  "scripts": {