An $attachments() rune alongside with $props() #16756
                  
                    
                      sourcecaster
                    
                  
                
                  started this conversation in
                Ideas
              
            Replies: 2 comments 6 replies
-
| The whole point is that everything can be spread along the rest of the properties and events. Why do you want to separate it? | 
Beta Was this translation helpful? Give feedback.
                  
                    0 replies
                  
                
            -
| If you already know you're getting an attachment, you can explicitly define it in your props: <script>
-	let { title, text, ...props } = $props();
+	let { title, text, styling, ...props } = $props();
-	let customStylingAttachment = props[Object.getOwnPropertySymbols(props)[0]];
</script>
-<div {@attach customStylingAttachment}>
+<div {@attach styling}>
... whatever goes here with {title} and {text}
</div>Then you pass the attachment function as a simple prop. | 
Beta Was this translation helpful? Give feedback.
                  
                    6 replies
                  
                
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
-
Right now the documentation says:
When used on a component, {@Attach ...} will create a prop whose key is a Symbol. If the component then spreads props onto an element, the element will receive those attachments.
Which makes handling attachments inside the component a bit tricky, basically I'm using this approach:
Probably it would be nice to use something like:
Beta Was this translation helpful? Give feedback.
All reactions