[Jifty-commit] jifty branch, master, updated. jifty-1.10228-8-gbab8aa1
Jifty commits
jifty-commit at lists.jifty.org
Thu Apr 14 15:45:52 EDT 2011
The branch, master has been updated
via bab8aa1f75ed7c1479516fc39d781a00b891835b (commit)
from 678f9ac35598ff9f30c3c0c30f5c96e1edcca704 (commit)
Summary of changes:
Makefile.PL | 2 +-
lib/Jifty/Client.pm | 16 +++++++---------
lib/Jifty/Test/WWW/Mechanize.pm | 16 +++++++---------
3 files changed, 15 insertions(+), 19 deletions(-)
- Log -----------------------------------------------------------------
commit bab8aa1f75ed7c1479516fc39d781a00b891835b
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Thu Apr 14 14:29:21 2011 -0400
Replace XML::XPath with HTML::TreeBuilder::XPath
XML::XPath is 2003-era crap that can't deal with HTML5 (it complains
about and other undefined entities) and depends on
XML::Parser which was originally Larry's expat bindings from 1998.
HTML::TreeBuilder::XPath is used by more modern projects like
Web::Scraper.
We only use XPath for one thing in Jifty - for pulling out field
validation errors from a rendered document. It might be nice to
kill this kind of dependency entirely.
diff --git a/Makefile.PL b/Makefile.PL
index 59e8011..de738cd 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -46,6 +46,7 @@ requires('HTML::Entities');
requires('HTML::Lint');
requires('HTML::Mason' => 1.3101); # HTML::Mason::Exceptions HTML::Mason::FakeApache HTML::Mason::MethodMaker HTML::Mason::Request HTML::Mason::Utils
requires('HTML::Mason::Plugin');
+requires('HTML::TreeBuilder::XPath');
requires('HTTP::Cookies');
requires('HTTP::Date');
requires('Hash::Merge', '0.12');
@@ -91,7 +92,6 @@ requires('URI' => 1.31);
requires('URI::Escape');
requires('XML::Writer' => '0.601');
requires('XML::Simple');
-requires('XML::XPath');
requires('version');
if (can_cc()) {
diff --git a/lib/Jifty/Client.pm b/lib/Jifty/Client.pm
index b664ddf..0e47f0f 100644
--- a/lib/Jifty/Client.pm
+++ b/lib/Jifty/Client.pm
@@ -8,7 +8,7 @@ delete $ENV{'http_proxy'}; # Otherwise WWW::Mechanize tries to go through your H
use Jifty::YAML;
use HTTP::Cookies;
-use XML::XPath;
+use HTML::TreeBuilder::XPath;
use List::Util qw(first);
use Carp;
@@ -263,17 +263,15 @@ sub field_error_text {
my $field = shift;
# Setup the XPath processor and the ID we're looking for
- my $xp = XML::XPath->new( xml => $self->content );
+ my $tree = HTML::TreeBuilder::XPath->new;
+ $tree->parse($self->content);
+ $tree->eof;
+
my $id = "errors-J:A:F-$field-$moniker";
# Search for the span containing that error
- my $nodeset = $xp->findnodes(qq{//span[\@id = "$id"]});
- return unless $nodeset->size == 1;
-
- # Note that $xp->getNodeText does not actually return undef for nodes that
- # aren't found, even though it's documented to. Thus the workaround above.
- return $xp->getNodeText(qq{//span[\@id = "$id" ]});
-}
+ return $tree->findvalue(qq{//span[\@id = "$id"]});
+}
=head2 uri
diff --git a/lib/Jifty/Test/WWW/Mechanize.pm b/lib/Jifty/Test/WWW/Mechanize.pm
index c2b1a7a..f43c215 100644
--- a/lib/Jifty/Test/WWW/Mechanize.pm
+++ b/lib/Jifty/Test/WWW/Mechanize.pm
@@ -11,7 +11,7 @@ use Jifty::YAML;
use HTML::Lint;
use Test::HTML::Lint qw();
use HTTP::Cookies;
-use XML::XPath;
+use HTML::TreeBuilder::XPath;
use List::Util qw(first);
use Plack::Test;
use Carp;
@@ -351,17 +351,15 @@ sub field_error_text {
my $field = shift;
# Setup the XPath processor and the ID we're looking for
- my $xp = XML::XPath->new( xml => $self->content );
+ my $tree = HTML::TreeBuilder::XPath->new;
+ $tree->parse($self->content);
+ $tree->eof;
+
my $id = "errors-J:A:F-$field-$moniker";
# Search for the span containing that error
- my $nodeset = $xp->findnodes(qq{//span[\@id = "$id"]});
- return unless $nodeset->size == 1;
-
- # Note that $xp->getNodeText does not actually return undef for nodes that
- # aren't found, even though it's documented to. Thus the workaround above.
- return $xp->getNodeText(qq{//span[\@id = "$id" ]});
-}
+ return $tree->findvalue(qq{//span[\@id = "$id"]});
+}
=head2 uri
-----------------------------------------------------------------------
More information about the Jifty-commit
mailing list