refactor: refactor

This commit is contained in:
Nolan Lawson 2022-03-27 20:35:24 -07:00
parent 794db4e7e7
commit 2accc46d8f
2 changed files with 3 additions and 5 deletions

View File

@ -1,6 +1,3 @@
// same as the one used for PinaforeEmoji
export const FONT_FAMILY = '"Twemoji Mozilla","Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol",' +
'"Noto Color Emoji","EmojiOne Color","Android Emoji",sans-serif'
export const COUNTRY_FLAG_FONT_FAMILY = 'Twemoji Mozilla'
export const COUNTRY_FLAG_FONT_URL = '/TwemojiCountryFlags.woff2'

View File

@ -1,14 +1,15 @@
import { polyfillCountryFlagEmojis } from 'country-flag-emoji-polyfill'
import { store } from '../store.js'
import { COUNTRY_FLAG_FONT_FAMILY, COUNTRY_FLAG_FONT_URL } from '../../_static/fonts.js'
let polyfilled = false
const COUNTRY_FLAG_FONT_URL = '/TwemojiCountryFlags.woff2'
export function countryFlagEmojiPolyfill () {
if (!polyfilled) {
polyfilled = true
const numStylesBefore = document.head.querySelectorAll('style').length
polyfillCountryFlagEmojis(COUNTRY_FLAG_FONT_FAMILY, COUNTRY_FLAG_FONT_URL)
polyfillCountryFlagEmojis('Twemoji Mozilla', COUNTRY_FLAG_FONT_URL)
const numStylesAfter = document.head.querySelectorAll('style').length
// if a style was added, then the polyfill was activated
const polyfillActivated = numStylesAfter !== numStylesBefore