From 77e6e35bd5e738e43e1f94b418e44228a3cb8c36 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Fri, 24 Nov 2023 09:17:13 -0800 Subject: [PATCH] fix: avoid newer JS syntax to support old Safari (#380) --- rollup.config.js | 13 ++++++++++++- shims/svelte-v3-shim.js | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/rollup.config.js b/rollup.config.js index 03504e1..81039c0 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -78,7 +78,18 @@ const baseConfig = { const entryPoints = [ { input: './src/picker/PickerElement.js', - output: './picker.js' + output: './picker.js', + plugins: [ + // Replace newer syntax in Svelte v4 to avoid breaking iOS <13.4 + // https://github.com/nolanlawson/emoji-picker-element/pull/379 + replace({ + 'array_like_or_iterator?.length': 'array_like_or_iterator && array_like_or_iterator.length', + '$$ = undefined;': '', // not necessary to initialize class prop to undefined + '$$set = undefined;': '', // not necessary to initialize class prop to undefined + delimiters: ['', ''], + preventAssignment: true + }) + ] }, { input: './src/database/Database.js', diff --git a/shims/svelte-v3-shim.js b/shims/svelte-v3-shim.js index b04a9b3..8dfa849 100644 --- a/shims/svelte-v3-shim.js +++ b/shims/svelte-v3-shim.js @@ -3,7 +3,7 @@ // this code is copied from svelte v4 /* eslint-disable camelcase */ export function ensure_array_like_shim (array_like_or_iterator) { - return array_like_or_iterator?.length !== undefined + return (array_like_or_iterator && array_like_or_iterator.length !== undefined) ? array_like_or_iterator : Array.from(array_like_or_iterator) }