Determine Slot Content Type #1017
walmartwarlord
started this conversation in
Proposal
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
Propose adding a method or property to Astro that allows developers to determine whether a slot contains a string or an HTML Element.
Background & Motivation
In Astro, it's currently challenging to differentiate between slots containing plain text and those containing HTML Elements. This limitation affects component authors' ability to make decisions based on the type of content passed to a slot, leading to less flexible and adaptable components.
Goals
Example
If the proposal is implemented, component authors could do something like this:
In this example,
Astro.slots.isHTMLElement()
is a hypothetical new method that would returntrue
if the slot contains an HTML Element, andfalse
if it contains only a string.This would allow components to adapt their structure based on the content they receive, providing a more flexible and powerful component authoring experience.
Beta Was this translation helpful? Give feedback.
All reactions