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

@font-face doesn't respect scope when compiling #4251

Closed
badlydrawnrob opened this issue Dec 7, 2023 · 2 comments
Closed

@font-face doesn't respect scope when compiling #4251

badlydrawnrob opened this issue Dec 7, 2023 · 2 comments
Labels

Comments

@badlydrawnrob
Copy link

To reproduce:

You can see the issue on this preview — although in my version, I have a file called root.less that's importing the @font-face code from another file.

The following scope isn't respected:

:root {
  @font-face {
    font-family: "DejaVu Sans";
    src: url("_DejaVuSans-Bold");
    font-style: normal;
    font-weight: 700;
  }
  --css-variable: "DejaVu Sans";
}

The CSS variable is scoped to :root, but the @font-face is outside of root when compiled. I'm not sure if this is by design, or a bug. There is some conversation about where it should be defined — but I feel putting it inside :root should be valid.

It just means my css variables are named before the @font-face in the main.css compiled file — the CSS still seems to work, but it might cause problems in the future.

Expected behavior:

I expected the @font-face rule to be inside :root.

Environment information:

Less version 4.2.0 on Mac.

@matthew-dean
Copy link
Member

If it was inside :root, according to spec, it would be invalid. @font-face defines a global value. See: https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face

@badlydrawnrob
Copy link
Author

@matthew-dean Fair enough. It was unclear to how they're supposed to be declared from what I was reading.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants