HTML::O...t::Slot(3)
π HTML::O...t::Slot(3) β HTML Object DOM Slot Class, bestie! π
Straight from the User Contributed Perl Documentation: this is the manual for HTML::O...t::Slot(3), aka HTML::Object::DOM::Element::Slot. Itβs lowkey niche, highkey useful, and weβre gonna read it together. π«Ά
β¨ NAME β¨
HTML::Object::DOM::Element::Slot - HTML Object DOM Slot Class. Thatβs the name, and yes it is giving exactly what it says. π
π SYNOPSIS π
use HTML::Object::DOM::Element::Slot;
my $slot = HTML::Object::DOM::Element::Slot->new ||
die( HTML::Object::DOM::Element::Slot->error, "\n" );
π¦ VERSION π¦
Version check, bestie:
v0.2.0
πΈ DESCRIPTION πΈ
This interface from the Shadow DOM API is literally your access pass to the name and assigned nodes of an HTML slot element. Obsessed. β¨
π§ INHERITANCE π§
The family tree is iconic and exactly this:
+-----------------------+ +---------------------------+ +-------------------------+ +----------------------------+ +----------------------------------+
| HTML::Object::Element | --> | HTML::Object::EventTarget | --> | HTML::Object::DOM::Node | --> | HTML::Object::DOM::Element | --> | HTML::Object::DOM::Element::Slot |
+-----------------------+ +---------------------------+ +-------------------------+ +----------------------------+ +----------------------------------+
π PROPERTIES π
Inherits properties from its parent HTML::Object::DOM::Element.
π name
A string used to get and set the slotβs name. Simple, cute, effective. π
Example:
my $slots = this->shadowRoot->querySelectorAll('slot');
$slots->[1]->addEventListener( slotchange => sub
{
my $nodes = $slots->[1]->assignedNodes();
say( 'Element in Slot "' . $slots->[1]->name . '" changed to "' . $nodes->[0]->outerHTML . '".');
});
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLSlotElement/name
π₯ METHODS π₯
Inherits methods from its parent HTML::Object::DOM::Element.
πͺ assign
Under perl environment, this always returns undef.
Under JavaScript, this sets the manually assigned nodes for this slot to the given nodes.
Example:
sub UpdateDisplayTab
{
my( $elem, $tabIdx ) = @_;
my $shadow = $elem->shadowRoot;
my $slot = $shadow->querySelector( 'slot' );
my $panels = $elem->querySelectorAll( 'tab-panel' );
if( $panels->length && $tabIdx && $tabIdx <= $panels->length )
{
$slot->assign( $panels->[ $tabIdx - 1 ] );
}
else
{
$slot->assign();
}
}
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLSlotElement/assign
π¦ assignedElements
Under perl environment, this always returns undef.
Under JavaScript, this returns a sequence of the elements assigned to this slot (and no other nodes). If the flatten option is set to true, it also returns the assigned elements of any other slots that are descendants of this slot. If no assigned nodes are found, it returns the slotβs fallback content.
Example:
my $slots = this->shadowRoot->querySelector('slot');
my $elements = $slots->assignedElements({ flatten => 1 });
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLSlotElement/assignedElements
β assignedNodes
Under perl environment, this always returns undef.
Under JavaScript, this returns a sequence of the nodes assigned to this slot, and if the flatten option is set to true, the assigned nodes of any other slots that are descendants of this slot. If no assigned nodes are found, it returns the slotβs fallback content.
Example:
my $slots = this->shadowRoot->querySelectorAll('slot');
$slots->[1]->addEventListener( slotchange => sub
{
my $nodes = $slots->[1]->assignedNodes();
say( 'Element in Slot "' . $slots->[1]->name . '" changed to "' . $nodes->[0]->outerHTML . '".' );
});
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLSlotElement/assignedNodes
π EVENTS π
Event listeners for those events can also be found by prepending "on" before the event type:
For example, "slotchange" event listeners can be set also with "onslotchange" method:
$e->onslotchange(sub{ # do something });
# or as an lvalue method
$e->onslotchange = sub{ # do something };
π slotchange
Fired on an HTMLSlotElement instance (<slot> element) when the node(s) contained in that slot change. The drama of it all. π
Example:
my $slots = this->shadowRoot->querySelectorAll('slot');
$slots->[1]->addEventListener( slotchange => sub
{
my $nodes = $slots->[1]->assignedNodes();
say( 'Element in Slot "' . $slots->[1]->name . '" changed to "' . $nodes->[0]->outerHTML . '".' );
});
See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLSlotElement/slotchange_event
π AUTHOR π
Jacques Deguest <jack@deguest.jp>
π SEE ALSO π
- Mozilla documentation:
https://developer.mozilla.org/en-US/docs/Web/API/HTMLSlotElement - Mozilla documentation on slot element:
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/slot
π COPYRIGHT & LICENSE π
Copyright(c) 2022 DEGUEST Pte. Ltd.
All rights reserved
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
xoxo, bestie π β this page is signed off with perl v5.42.2, dated 2026-02-15, from the manual HTML::O...t::Slot(3). Bye and slay! π
π¦ where this page comes from
- alpine 3.24: perl-html-object-doc 0.6.0-r1 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms