3 use Test::More tests => 8;
7 use_ok( "HTML::Element" );
12 HTML::Element->new( 'img', (
13 src => 'damian-conway-in-a-dress.jpg',
14 height=>540, width=>100, border=>0,
15 alt => "A few bottles of Chech'tluth later...",
18 my $href = '/report/fullcsv';
19 my $literal_href = HTML::Element->new(
20 '~literal', 'text' => "window.location.href='$href'"
22 $img->attr(onClick => $literal_href);
27 isa_ok( $img, 'HTML::Element' );
28 my $html = $img->as_HTML;
31 like( $html, qr/<img .+ \/>/, "Tag is self-closed" );
32 like( $html, qr/ height="540" /, "Height is quoted" );
33 like( $html, qr/ border="0" /, "Border is quoted" );
34 like( $html, qr/ width="100" /, "Width is quoted" );
37 qr! onclick="window.location.href='$href'!,
38 "Literal text is preserved"
40 like( $html, qr/ alt="A few bottles of Chech'tluth later..." /, "Alt tag is quoted and escaped" );