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

[BUG] anchor-name doesn't respect CSS cascade #218

Closed
mmalerba opened this issue Jul 21, 2024 · 2 comments · Fixed by #222
Closed

[BUG] anchor-name doesn't respect CSS cascade #218

mmalerba opened this issue Jul 21, 2024 · 2 comments · Fixed by #222
Labels
bug Something isn't working

Comments

@mmalerba
Copy link
Contributor

Describe the bug
The anchor-name property doesn't respect the CSS cascade. For example:

.anchor {
  anchor-name: --name;
}
.anchor {
  anchor-name: --other-name;
}
.positioned {
  position: absolute;
  top: anchor(--name, bottom); // this should not anchor to `.anchor`, but currently does.
}

To Reproduce
I created a test demonstrating the issue here: main...mmalerba:css-anchor-positioning:cascade

Expected behavior
The anchor function should only match the anchor-name that is actually applied by the cascade

Additional context
This can be solved by shifting anchor-name into a custom property, but the custom property inherits by default, so we would either have to disable that with @property (potentially unacceptable due to browser support?) or just be careful to verify we're not reading inherited values. This is how I handled a similar issue for anchor-scope: 32f04d8 (#217)

@mmalerba mmalerba added the bug Something isn't working label Jul 21, 2024
@jgerigmeyer
Copy link
Member

Good catch! I like the approach you used in #217, so that would be my leaning.

@jgerigmeyer
Copy link
Member

I think this solution might also fix #212?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants