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

[css-scoping] The ::slotted() doesn't say anything about the fallback slot content. #1535

Closed
praveenpuglia opened this issue Jun 18, 2017 · 2 comments

Comments

@praveenpuglia
Copy link
Contributor

The spec says

The ::slotted() pseudo-element represents the elements assigned, after flattening, to a slot. This pseudo-element only exists on slots.

If I now arrive at a situation where the fallback for a slot is used, I am guessing that it'll come up in the flattened view as well. That would mean that I can find use the ::slotted() to query the fallback markup elements and apply styles to them?

It's not really clear how to style the fallback content in general.

Currently I am doing something like this inside my shadow-root styles.

/* works but not sure if this is the best way to do it. */

slot[name="profile-picture"] svg {
  width: 64px;
  height: 64px;
}

/* doesn't */
::slotted(svg) {
  width: var(--card-picture-dimension, 64px);
  height: var(--card-picture-dimension, 64px);
}
@tabatkins
Copy link
Member

The fallback content is just the DOM children of the slot element, so you can target and style them normally. Your first example is indeed correct.

@praveenpuglia
Copy link
Contributor Author

Thanks for the clarification. :)

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

No branches or pull requests

2 participants