Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 42 additions & 6 deletions src/core/dom-renderer/domRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
} from './domRendererUtils.js';

// Feature detection for legacy brousers
const _styleRef: any =

Check warning on line 38 in src/core/dom-renderer/domRenderer.ts

View workflow job for this annotation

GitHub Actions / build-test

Unexpected any. Specify a different type
typeof document !== 'undefined' ? document.documentElement?.style || {} : {};

const supportsObjectFit: boolean = 'objectFit' in _styleRef;
Expand Down Expand Up @@ -109,7 +109,7 @@
for (const prop in task.propsEnd) {
const start = task.propsStart[prop]!;
const end = task.propsEnd[prop]!;
(task.node.props as any)[prop] = interpolateProp(prop, start, end, t);

Check warning on line 112 in src/core/dom-renderer/domRenderer.ts

View workflow job for this annotation

GitHub Actions / build-test

Unsafe member access [prop] on an `any` value

Check warning on line 112 in src/core/dom-renderer/domRenderer.ts

View workflow job for this annotation

GitHub Actions / build-test

Unexpected any. Specify a different type
}

updateNodeStyles(task.node);
Expand All @@ -134,7 +134,7 @@

constructor(
public node: DOMNode,
props: Partial<lng.INodeAnimateProps<any>>,

Check warning on line 137 in src/core/dom-renderer/domRenderer.ts

View workflow job for this annotation

GitHub Actions / build-test

Unexpected any. Specify a different type
rawSettings: Partial<lng.AnimationSettings>,
) {
this.settings = {
Expand All @@ -152,7 +152,7 @@

for (const [prop, value] of Object.entries(props)) {
if (value != null && typeof value === 'number') {
this.propsStart[prop] = (node.props as any)[prop];

Check warning on line 155 in src/core/dom-renderer/domRenderer.ts

View workflow job for this annotation

GitHub Actions / build-test

Unsafe member access [prop] on an `any` value

Check warning on line 155 in src/core/dom-renderer/domRenderer.ts

View workflow job for this annotation

GitHub Actions / build-test

Unexpected any. Specify a different type

Check warning on line 155 in src/core/dom-renderer/domRenderer.ts

View workflow job for this annotation

GitHub Actions / build-test

Unsafe assignment of an `any` value
this.propsEnd[prop] = value;
}
}
Expand Down Expand Up @@ -214,7 +214,7 @@

function animate(
this: DOMNode,
props: Partial<lng.INodeAnimateProps<any>>,

Check warning on line 217 in src/core/dom-renderer/domRenderer.ts

View workflow job for this annotation

GitHub Actions / build-test

Unexpected any. Specify a different type
settings: Partial<lng.AnimationSettings>,
): lng.IAnimationController {
return new AnimationController(this, props, settings);
Expand Down Expand Up @@ -857,16 +857,29 @@

node.imgEl.addEventListener('error', () => {
node.imageLoading = false;

const failedSrc =
node.imgEl?.dataset.pendingSrc || node.lazyImagePendingSrc || '';

const fallback = node.props.fallbackImage;

Check failure on line 864 in src/core/dom-renderer/domRenderer.ts

View workflow job for this annotation

GitHub Actions / build-test

Property 'fallbackImage' does not exist on type 'IRendererNodeProps'.
if (
fallback &&
node.imgEl &&
node.imgEl.dataset.rawSrc !== fallback
) {
node.imgEl.dataset.pendingSrc = fallback;
node.imgEl.dataset.rawSrc = fallback;
node.imgEl.src = fallback;
return;
}

node.showBackgroundLayer();
if (node.imgEl) {
node.imgEl.removeAttribute('src');
node.imgEl.style.display = 'none';
node.imgEl.removeAttribute('data-rawSrc');
}

const failedSrc =
node.imgEl?.dataset.pendingSrc || node.lazyImagePendingSrc || '';

const payload: lng.NodeTextureFailedPayload = {
type: 'texture',
error: new Error(`Failed to load image: ${failedSrc}`),
Expand Down Expand Up @@ -977,15 +990,28 @@

node.imgEl.addEventListener('error', () => {
node.imageLoading = false;

const failedSrc =
node.imgEl?.dataset.pendingSrc || node.lazyImagePendingSrc || '';

const fallback = node.props.fallbackImage;

Check failure on line 997 in src/core/dom-renderer/domRenderer.ts

View workflow job for this annotation

GitHub Actions / build-test

Property 'fallbackImage' does not exist on type 'IRendererNodeProps'.
if (
fallback &&
node.imgEl &&
node.imgEl.dataset.rawSrc !== fallback
) {
node.imgEl.dataset.pendingSrc = fallback;
node.imgEl.dataset.rawSrc = fallback;
node.imgEl.src = fallback;
return;
}

if (node.imgEl) {
node.imgEl.removeAttribute('src');
node.imgEl.style.display = 'none';
node.imgEl.removeAttribute('data-rawSrc');
}

const failedSrc =
node.imgEl?.dataset.pendingSrc || node.lazyImagePendingSrc || '';

const payload: lng.NodeTextureFailedPayload = {
type: 'texture',
error: new Error(`Failed to load image: ${failedSrc}`),
Expand Down Expand Up @@ -1285,6 +1311,7 @@
rotation: props.rotation ?? 0,
rtt: props.rtt ?? false,
placeholderColor: props.placeholderColor ?? 0,
fallbackImage: props.fallbackImage ?? null,

Check failure on line 1314 in src/core/dom-renderer/domRenderer.ts

View workflow job for this annotation

GitHub Actions / build-test

Property 'fallbackImage' does not exist on type 'Partial<IRendererNodeProps>'.

Check failure on line 1314 in src/core/dom-renderer/domRenderer.ts

View workflow job for this annotation

GitHub Actions / build-test

Object literal may only specify known properties, and 'fallbackImage' does not exist in type 'IRendererNodeProps'.
data: {},
imageType: props.imageType,
};
Expand Down Expand Up @@ -1829,6 +1856,15 @@
updateNodeStyles(this);
}

get fallbackImage(): string | null {
return this.props.fallbackImage ?? null;

Check failure on line 1860 in src/core/dom-renderer/domRenderer.ts

View workflow job for this annotation

GitHub Actions / build-test

Property 'fallbackImage' does not exist on type 'IRendererNodeProps'.
}

set fallbackImage(v: string | null) {
if (this.props.fallbackImage === v) return;

Check failure on line 1864 in src/core/dom-renderer/domRenderer.ts

View workflow job for this annotation

GitHub Actions / build-test

Property 'fallbackImage' does not exist on type 'IRendererNodeProps'.
this.props.fallbackImage = v;

Check failure on line 1865 in src/core/dom-renderer/domRenderer.ts

View workflow job for this annotation

GitHub Actions / build-test

Property 'fallbackImage' does not exist on type 'IRendererNodeProps'.
}

get absX(): number {
const parent = this.props.parent;
return (
Expand Down
2 changes: 2 additions & 0 deletions src/core/elementNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ const LightningRendererNonAnimatingProps = [
'offsetY',
'overflowSuffix',
'placeholderColor',
'fallbackImage',
'preventCleanup',
'rtt',
'scrollable',
Expand Down Expand Up @@ -793,6 +794,7 @@ export class ElementNode {
text: undefined,
ignoreParentAlpha: undefined,
placeholderColor: undefined,
fallbackImage: undefined,
};
this.children = [];

Expand Down
Loading