SlotFill: remove registration API from useSlot result #67070
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Follow-up to #67000 where @youknowriad pointed out in review that the API methods (
registerSlot
etc) returned from__experimentalUseSlot
are not used anywhere. This PR removes the API methods and leaves only theslot
object.I also update the
Fill
component to not useuseSlot
at all: theregister/unregisterFill
can be accessed through context and to find out if there is a registeredslot
and whether it has a DOM element, we can look atregistry.slots
directly.I was also searching for usages of
__experimentalUseSlot
. And it seems to be not really used by plugins. Plugins like WooCommerce or Kubio want to know whether a particular slot has registered fills. If there are no fills, they usually don't render the slot at all. They use__experimentalUseSlotFills( name ).fills.length > 0
to determine that. The__experimentalUseSlot
function is called only for backward compatibility, because before #44642 there was only__experimentalUseSlot
and it returned also the fills.The only place where
__experimentalUseSlot
is really used is thePopover
component, to determine whether a slot with given name is registered.If we wanted to stabilize the
useSlot
API and remove the__experimental
prefix, we need to solve these two use cases:name
) has any registered fills. This is widely used to render slots conditionally, only if there are fills registered. Because even an empty slot renders an element and is visible in the UI, and that's often not wanted.name
) is registered at all.