Skip to content

Commit

Permalink
filter nodes earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Dec 10, 2014
1 parent 5a763de commit bd8bb40
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
12 changes: 4 additions & 8 deletions lib/Mojo/DOM.pm
Expand Up @@ -10,7 +10,6 @@ use overload
# "Fry: This snow is beautiful. I'm glad global warming never happened.
# Leela: Actually, it did. But thank God nuclear winter canceled it out."
use Carp 'croak';
use List::Util 'first';
use Mojo::Collection;
use Mojo::DOM::CSS;
use Mojo::DOM::HTML;
Expand Down Expand Up @@ -68,11 +67,7 @@ sub attr {
return $self;
}

sub children {
my $self = shift;
return _select(
$self->_collect(grep { $_->[0] eq 'tag' } _nodes($self->tree)), @_);
}
sub children { _select($_[0]->_collect(_nodes($_[0]->tree, 1)), $_[1]) }

sub content {
my $self = shift;
Expand Down Expand Up @@ -308,7 +303,8 @@ sub _maybe { $_[1] ? _build($_[0], $_[1], $_[0]->xml) : undef }

sub _nodes {
return unless my $tree = shift;
return @$tree[_start($tree) .. $#$tree];
my @nodes = @$tree[_start($tree) .. $#$tree];
return shift() ? grep { $_->[0] eq 'tag' } @nodes : @nodes;
}

sub _offset {
Expand Down Expand Up @@ -398,7 +394,7 @@ sub _wrap {
# Find innermost tag
my $current;
my $first = $new = $self->_parse($new);
$current = $first while $first = first { $_->[0] eq 'tag' } _nodes($first);
$current = $first while $first = (_nodes($first, 1))[0];
return $self unless $current;

# Wrap content
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojo/IOLoop/Server.pm
Expand Up @@ -100,7 +100,7 @@ sub listen {
$tls->{SSL_cipher_list} = $args->{tls_ciphers} if $args->{tls_ciphers};
}

sub port { shift->handle->sockport }
sub port { shift->{handle}->sockport }

sub start {
my $self = shift;
Expand Down Expand Up @@ -308,7 +308,7 @@ TLS verification mode, defaults to C<0x03>.
my $port = $server->port;
Get TCP port this server is listening on.
Get port this server is listening on.
=head2 start
Expand Down

0 comments on commit bd8bb40

Please sign in to comment.