fix: avoid newer JS syntax to support old Safari (#380)

This commit is contained in:
Nolan Lawson 2023-11-24 09:17:13 -08:00 committed by GitHub
parent 497681f211
commit 77e6e35bd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View File

@ -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',

View File

@ -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)
}