Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fontFamily being set to undefined #252

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,21 @@ const stringHandlers = {
if (Array.isArray(val)) {
return val.map(fontFamily).join(",");
} else if (typeof val === "object") {
injectStyleOnce(val.src, "@font-face", [val], false);
return `"${val.fontFamily}"`;
let key = val.src;
let fontFamily = val.fontFamily;

// More than likely this object will be an OrderedElement type
// which will require usage of its getters methods
if (val instanceof OrderedElements) {
// We need to generate a unique key by which we can identify
// this declaration in the the 'alreadyInjected' object
key = `fontface_${hashObject(val)}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we're not just using val.get('src') to be consistent with how we generate the key normally?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late reply, was away. No, there isn't a reason I didn't use val.get(). Good point. I'll change it to be consistent like you said. Thanks. And I'll also add the tests.

fontFamily = val.get('fontFamily');
}

injectStyleOnce(key, "@font-face", [val], false);

return `"${fontFamily}"`;
} else {
return val;
}
Expand Down