X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDOM%2FTiny%2FHTML.pm;h=dfcb190ca5c1e6408fa199e52812c4104f07176a;hb=d066f9b8911f3921dade7add91af94228eaa5a45;hp=042ae5fd7a764434b86726e2e22ce2d4444865c7;hpb=5a70ee9d2295cf74db3b0e2476e906cdcaee1ff3;p=catagits%2FDOM-Tiny.git diff --git a/lib/DOM/Tiny/HTML.pm b/lib/DOM/Tiny/HTML.pm index 042ae5f..dfcb190 100644 --- a/lib/DOM/Tiny/HTML.pm +++ b/lib/DOM/Tiny/HTML.pm @@ -4,7 +4,6 @@ use strict; use warnings; use DOM::Tiny::Entities qw(html_escape html_unescape); use Scalar::Util 'weaken'; -use Class::Tiny::Chained 'xml', { tree => sub { ['root'] } }; our $VERSION = '0.001'; @@ -95,6 +94,25 @@ my %BLOCK = map { $_ => 1 } ( qw(tbody td template textarea tfoot th thead title tr tt u ul xmp) ); +sub new { + my $class = shift; + bless @_ ? @_ > 1 ? {@_} : {%{$_[0]}} : {}, ref $class || $class; +} + +sub tree { + my $self = shift; + return exists $self->{tree} ? $self->{tree} : ($self->{tree} = ['root']) unless @_; + $self->{tree} = shift; + return $self; +} + +sub xml { + my $self = shift; + return $self->{xml} unless @_; + $self->{xml} = shift; + return $self; +} + sub parse { my ($self, $html) = (shift, "$_[0]"); @@ -311,8 +329,15 @@ auto detection based on processing instructions. =head1 METHODS -L inherits a constructor from L, -and implements the following methods. +L implements the following methods. + +=head2 new + + my $html = DOM::Tiny::HTML->new; + my $html = DOM::Tiny::HTML->new(xml => 1); + my $html = DOM::Tiny::HTML->new({xml => 1}); + +Construct a new hash-based L object. =head2 parse