From: Simon Elliott Date: Fri, 20 May 2011 17:48:12 +0000 (+0100) Subject: some simple shorthand helpers. X-Git-Tag: 0.009009~1^2~13 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FHTML-Zoom.git;a=commitdiff_plain;h=5ad4b46120e8047a91bd9759da91b414e7a4a0cc some simple shorthand helpers. add_class remove_class set_class set_id --- diff --git a/t/actions.t b/t/actions.t index 4e3315b..6b7c12c 100644 --- a/t/actions.t +++ b/t/actions.t @@ -55,6 +55,14 @@ is( 'set attribute on existing attribute' ); +($expect = $tmpl) =~ s/class="main"/class="foo"/; + +is( + run_for { $_->set_attr({ name => 'class', value => 'foo' }) }, + $expect, + 'set attribute on existing attribute (shorthand)' +); + ($expect = $tmpl) =~ s/class="main"/class="main" foo="bar"/; is( @@ -71,6 +79,22 @@ is( 'add attribute on existing attribute' ); +($expect = $tmpl) =~ s/class="main"/class="main foo"/; + +is( + run_for { $_->add_class('foo') }, + $expect, + 'add attribute on existing attribute (shorthand)' +); + +($expect = $tmpl) =~ s/class="main"/class="main" id="foo"/; + +is( + run_for { $_->set_id('foo') }, + $expect, + 'set_id (shorthand)' +); + ($expect = $tmpl) =~ s/class="main"/class="main" foo="bar"/; is(