-
Notifications
You must be signed in to change notification settings - Fork 187
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
Check for already-injected @font-face rules by src - Fixes #80 #82
Conversation
Hey @xymostech && @jlfwong, This changeset modifies the call to `injectStyleOnce` to use `src` as the key, rather than `fontName` [which does not need to be unique](http://fonts.googleapis.com/css?family=Inconsolata:400,700). I added a quick test as well, let me know if you'd like it to be more thorough. You can also [see the fix in action on my cloned Aphrodite output](https://output.jsbin.com/yujaqagiho?code=%7B%0A%20%20%22test%22%3A%20%7B%0A%20%20%20%20fontFamily%3A%20%5B%7B%0A%20%20%20%20%20%20fontStyle%3A%20%22normal%22%2C%0A%20%20%20%20%20%20fontWeight%3A%20%22normal%22%2C%0A%20%20%20%20%20%20fontFamily%3A%20%22My%20Font%22%2C%0A%20%20%20%20%20%20src%3A%20%27url%28blah%29%20format%28%22woff%22%29%2C%20url%28blah%29%20format%28%22truetype%22%29%27%0A%20%20%20%20%7D%2C%20%7B%0A%20%20%20%20%20%20fontStyle%3A%20%22italic%22%2C%0A%20%20%20%20%20%20fontWeight%3A%20%22normal%22%2C%0A%20%20%20%20%20%20fontFamily%3A%20%22My%20Font%22%2C%0A%20%20%20%20%20%20src%3A%20%27url%28blahitalic%29%20format%28%22woff%22%29%2C%20url%28blahitalic%29%20format%28%22truetype%22%29%27%0A%20%20%20%20%7D%5D%0A%20%20%7D%0A%7D).
@@ -43,6 +43,10 @@ export const recursiveMerge = (a, b) => { | |||
return ret; | |||
}; | |||
|
|||
export const uniquify = (values) => { | |||
return [...new Set(values)]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure we guarantee that people have a Set
polyfill, so I don't think this will work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Looks like our build script doesn't polyfill it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing this was already the plan, but I'd rather just not use Set
than change this to include the polyfill (in the interest of keeping byte size down).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah we're on the same page. Since outputting unique font-family
s isn't important we can skip all of this.
This fixes #80, correct? |
Yep fixes #80! It's in the commit message so it'll auto-close if merged. |
Kk after some revert-revert-reverts I removed the unique font style stuff. This is good for a re-review. |
One line change accompanied by lots of tests -- this is my kinda change 😄 LGTM, but I only skimmed -- will leave to @xymostech for sign-off. |
Any update on this? |
Looks like I totally dropped the ball here! Looks like this still merges, so I'm gonna squash+merge. Thanks for the reminder @smdern |
Should this be a patch or a minor release? |
Hey @xymostech && @jlfwong,
This changeset modifies the call to
injectStyleOnce
to usesrc
as the key, rather thanfontName
which does not need to be unique.I added a quick test as well, let me know if you'd like it to be more thorough. You can also see the fix in action on my cloned Aphrodite output.
Input:
Current:
With fix (notice how "My Font" is uniquified in
font-family
):Maybe we want to think about only adding
@font-face
if it actually applies to thefont-family
rule? (i.e., only adding the second@font-family
if we usefont-style: italic
?) dunno