Skip to content

Commit

Permalink
fix(directive): fix font load with media
Browse files Browse the repository at this point in the history
  • Loading branch information
ThornWalli committed Feb 14, 2022
1 parent 8d7334f commit e892946
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/plugins/vFont/directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@ export default {

async function activateFonts (el, binding, vnode) {
const fonts = [].concat(binding.value);
await Promise.all(fonts.map(font => font.load()));

await Promise.all(
fonts
.filter(font => !font.media || global.matchMedia(font.media).matches)
.map(font => font.load())
);

el.classList.add(CLASS_FONT_ACTIVE);
vnode.context.fontActive = true;
vnode.context.$emit('load:font', fonts);
Expand Down

0 comments on commit e892946

Please sign in to comment.