taiga-family/maskito

๐Ÿš€ - Delete fallbacks for legacy Firefox

nsbarsukov opened this issue ยท 0 comments

Which package(s) are relevant/related to the feature request?

@maskito/core, @maskito/kit

Description

Maskito 1.0 has partial support for legacy Firefox (55+).
Firefox 55 was released more than 6 years ago!

In Maskito 2.0 we are going to bump Firefox browser support (Firefox 87+ will be minimum required version).


  1. For legacy Firefox (<87) which does not support beforeinput event we use keydown & paste events.
    /** TODO: drop it after browser support bump (Firefox 87+)
    * Also, replace union types `Event | TypedInputEvent` with `TypedInputEvent` inside:
    *** {@link handleDelete}
    *** {@link handleInsert}
    */
    this.eventListener.listen('keydown', event => this.handleKeydown(event));
    this.eventListener.listen('paste', event =>
    this.handleInsert(
    event,
    event.clipboardData?.getData('text/plain') || '',
    ),
    );

    Delete it and replace union types Event | TypedInputEvent with TypedInputEvent inside handleDelete & handleInsert methods of Maskito class.

  1. Use globalThis
    const globalObject = typeof window !== 'undefined' ? window : globalThis;
    // TODO: replace `globalObject` with `globalThis` after bumping Firefox to 65+
    // @see https://caniuse.com/?search=globalThis
    if (globalObject?.InputEvent) {

  1. Use String.trimStart and String.trimEnd
    .replace(LEADING_SPACES_REG, '') // TODO replace with `String.trimStart` after bumping Firefox to 61+

    .replace(TRAILING_SPACES_REG, '') // TODO replace with `String.trimEnd` after bumping Firefox to 61+

  1. Use Object.fromEntries:

/**
* @deprecated use `Object.fromEntries` instead
* (check browser support first https://caniuse.com/mdn-javascript_builtins_object_fromentries)
* ___
* TODO: after we bump Firefox to 63+ replace this function with `Object.fromEntries`.
* TODO: Add `es2019.object` to `tsconfig.json` => `compilerOptions.lib`.
*
*/
export function getObjectFromEntries<K extends number | string, V>(
keyValuePairs: Array<[K, V]>,
): Record<K, V> {
return keyValuePairs.reduce(
(obj, [key, val]) => ({...obj, [key]: val}),
{} as Record<K, V>,
);
}