NAME
Weasel::WidgetHandlers - Mapping elements to widget handlers
VERSION
version 0.32
SYNOPSIS
use Weasel::WidgetHandlers qw( register_widget_handler );
register_widget_handler(
'Weasel::Widgets::HTML::Radio', # Perl class handler
'HTML', # Widget group
tag_name => 'input',
attributes => {
type => 'radio',
});
register_widget_handler(
'Weasel::Widgets::Dojo::FilteringSelect',
'Dojo',
tag_name => 'span',
classes => ['dijitFilteringSelect'],
attributes => {
role => 'presentation',
...
});
DESCRIPTION
Widget handlers map HTML elements to Perl class instances based on the HTML tag and its attributes. The Perl class can be used to encapsulate interaction with the HTML element and its children, abstracting HTML DOM interactions into functional behaviours.
A widget may itself be composed of one or more child-widget. Eg, a form could be composed of several input fields and a button, all mapped to widgets to handle the interactions with the specific element type.
Classes can be developed and handlers registered for widgets which perform the same behaviours as basic HTML widgets, like the select
tag; eg., a Dojo Toolkit, Vue or React widgets could be mapped to specific classes which encapsulate the DOM interactions required to make these widgets transparent to the Perl code which is interacting with them. An example of a widget mimicing to be a select
tag is Weasel::Widgets::Dojo::Select.
DEPENDENCIES
SUBROUTINES/METHODS
- register_widget_handler($handler_class_name, $group_name, %conditions)
-
Registers
$handler_class_name
to be the instantiated widget returned for an element matching%conditions
into$group_name
.Weasel::Session
can select a subset of widgets to be applicable to that session by adding a subset of available groups to that session. - best_match_handler_class($driver, $_id, $groups)
-
Returns the best matching handler's class name, within the groups listed in the arrayref
$groups
, orundef
in case of no match.When
$groups
is undef, all registered handlers will be searched.When multiple handlers are considered "best match", the one last added to the group last mentioned in
$groups
is selected.
AUTHOR
Erik Huelsmann
CONTRIBUTORS
Erik Huelsmann Yves Lavoie
MAINTAINERS
Erik Huelsmann
BUGS AND LIMITATIONS
Bugs can be filed in the GitHub issue tracker for the Weasel project: https://github.com/perl-weasel/weasel/issues
SOURCE
The source code repository for Weasel is at https://github.com/perl-weasel/weasel
SUPPORT
Community support is available through perl-weasel@googlegroups.com.
LICENSE AND COPYRIGHT
(C) 2016-2023 Erik Huelsmann
Licensed under the same terms as Perl.