Svelte: Styling `ref:foo` on components

Created on 4 Aug 2018  路  7Comments  路  Source: sveltejs/svelte

We should decide whether we want to allow styling ref:foo { ... } when ref:foo refers to a component. (I'm not entirely sure what this would mean, with the non-cascading styles.) If we don't want to support it, we should provide more specific error messages when this is attempted.

bug rfc-1

Most helpful comment

came here to open the same issue. I think it should produce a warning.

All 7 comments

came here to open the same issue. I think it should produce a warning.

Would this mean that the user is trying to include styles declared on foo on their current component. Error could be something along the lines of Error: Styles from other components cannot be referenced using ref:foo?

Is general styling of components possible? Eg:

<div>
  <MyComponent class="foo" />
  <MyOtherComponent style="border: thick solid red;" />

If so, I would go for consistency and support styling via ref too.

@nkoehring Only if you support it by manually handling a style and a class prop.

<!-- Some component -->
<div {style} {class}>
    <h1>{title}</h1>
</div>

Okay makes sense because the component doesn't get anything wrapped around, right?

@nkoehring Yep. The class/style shouldn't always necessarily be assigned (only) to the "parent element".

Closing as not applicable to Svelte 3 (ref: no longer exists)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

clitetailor picture clitetailor  路  3Comments

thoughtspile picture thoughtspile  路  3Comments

noypiscripter picture noypiscripter  路  3Comments

plumpNation picture plumpNation  路  3Comments

st-schneider picture st-schneider  路  3Comments