NAME

HTML::Object::DOM::List - HTML Object DOM List Abstract Class

SYNOPSIS

package HTML::Object::DOM::VideoTrackList;
use parent qw( HTML::Object::DOM::List );

my $list = HTML::Object::DOM::VideoTrackList->new || d
    ie( HTML::Object::DOM::VideoTrackList->error, "\n" );

VERSION

v0.2.1

DESCRIPTION

This is an abstract class designed to be inherited by HTML::Object::DOM::TextTrackCueList, HTML::Object::DOM::TextTrackList and HTML::Object::DOM::VideoTrackList

It inherits from HTML::Object::EventTarget

INHERITANCE

+-----------------------+     +---------------------------+     +-------------------------+
| HTML::Object::Element | --> | HTML::Object::EventTarget | --> | HTML::Object::DOM::List |
+-----------------------+     +---------------------------+     +-------------------------+

METHODS

addEventListener

This is a variant from the usual addEventListener from HTML::Object::EventTarget. This method takes 3 arguments:

1. A dictionary hash reference

This dictionary contains a key for each event name and another hash reference as their value. That hash reference contains the following properties:

callback

Optional property whose value is a code reference to be called after creating the event and before dispatching it with "dispatchEvent" in HTML::Object::EventTarget. The purpose is to give it a chance to add some property value to the event like track for HTML::Object::DOM::TrackEvent fired by HTML::Object::DOM::TextTrackCueList, HTML::Object::DOM::TextTrackList and HTML::Object::DOM::VideoTrackList

event

The event name.

property

The module property or method name.

type

The type of callback to set for this property. Possible values are: add or remove

2. An event type
3. An event handler callback

When addEventListener is called, it will check if, for the given even type passed, there is an entry in the dictionary, and if there is it will enable an internal callback on the associated module property when there is any change to its underlying value.

This relies on "callback" in Module::Generic::Array and "callback" in Module::Generic::Scalar

That internal callback will be called when a change occurs, and will create an event of type type and call "dispatchEvent" in HTML::Object::EventTarget passing it the newly created event.

If a callback was specified in the dictionary for this event type, the callback code will be executed, and the whatever value added or removed will be passed to the callback as an hash reference and an hash property added or removed depending if the operation was to add or remove a value.

After having set this internal callback to monitor change, if any, this will call its parent addEventListener to register the event listener.

forEach

Calls foreach on the array object returned by "children" in HTML::Object::Element method.

length

Returns the size of the list, starting from 1.

push

Provided with some data and they will be appended to this list object.

AUTHOR

Jacques Deguest <jack@deguest.jp>

SEE ALSO

HTML::Object::EventTarget, HTML::Object::Event, HTML::Object::DOM::TextTrackCueList, HTML::Object::DOM::TextTrackCueList, HTML::Object::DOM::VideoTrackList

COPYRIGHT & LICENSE

Copyright(c) 2021 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.