From b8f9595adeead0aca5a9ab42ab076f90535b5265 Mon Sep 17 00:00:00 2001 From: Johann Schopplich Date: Tue, 12 Nov 2024 17:12:19 +0100 Subject: [PATCH] perf: use current date for placeholder id as well --- packages/core/src/constants.ts | 2 +- packages/core/src/utils/index.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/core/src/constants.ts b/packages/core/src/constants.ts index 7efb244..9d12e61 100644 --- a/packages/core/src/constants.ts +++ b/packages/core/src/constants.ts @@ -1,2 +1,2 @@ export const DEFAULT_PLACEHOLDER_SIZE = 32 -export const DEFAULT_IMAGE_PLACEHOLDER = `data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1 1' data-i=''%3E%3C/svg%3E` +export const DEFAULT_IMAGE_PLACEHOLDER = `data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1 1' data-id=''%3E%3C/svg%3E` diff --git a/packages/core/src/utils/index.ts b/packages/core/src/utils/index.ts index f71e19d..05d5371 100644 --- a/packages/core/src/utils/index.ts +++ b/packages/core/src/utils/index.ts @@ -18,7 +18,8 @@ export function toElementArray( } export function createIndexedImagePlaceholder(index: number) { - return DEFAULT_IMAGE_PLACEHOLDER.replace('data-i=\'\'', `data-i='${index}'`) + const now = Date.now() + return DEFAULT_IMAGE_PLACEHOLDER.replace('data-id=\'\'', `data-id='${now}-${index}'`) } export function calculateAspectRatioDimensions(aspectRatio: number, referenceSize: number) {