Skip to content

Commit

Permalink
more consistent names
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Dec 30, 2013
1 parent bf092f8 commit ac79e79
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Changes
@@ -1,5 +1,5 @@

4.64 2013-12-29
4.64 2013-12-30

4.63 2013-12-19
- Deprecated Mojolicious::secret in favor of Mojolicious::secrets.
Expand Down
10 changes: 5 additions & 5 deletions lib/Mojo/DOM.pm
Expand Up @@ -347,15 +347,15 @@ sub _text {
}

sub _trim {
my ($e, $trim) = @_;
my ($n, $trim) = @_;

# Disabled
return 0 unless $e && ($trim = defined $trim ? $trim : 1);
return 0 unless $n && ($trim = defined $trim ? $trim : 1);

# Detect "pre" tag
while ($e->[0] eq 'tag') {
return 0 if $e->[1] eq 'pre';
last unless $e = $e->[3];
while ($n->[0] eq 'tag') {
return 0 if $n->[1] eq 'pre';
last unless $n = $n->[3];
}

return 1;
Expand Down
10 changes: 5 additions & 5 deletions lib/Mojo/DOM/CSS.pm
Expand Up @@ -349,15 +349,15 @@ sub _sibling {

my $parent = $current->[3];
my $found;
for my $e (@$parent[($parent->[0] eq 'root' ? 1 : 4) .. $#$parent]) {
return $found if $e eq $current;
next unless $e->[0] eq 'tag';
for my $n (@$parent[($parent->[0] eq 'root' ? 1 : 4) .. $#$parent]) {
return $found if $n eq $current;
next unless $n->[0] eq 'tag';

# "+" (immediately preceding sibling)
if ($immediate) { $found = $self->_combinator($selectors, $e, $tree) }
if ($immediate) { $found = $self->_combinator($selectors, $n, $tree) }

# "~" (preceding sibling)
else { return 1 if $self->_combinator($selectors, $e, $tree) }
else { return 1 if $self->_combinator($selectors, $n, $tree) }
}

return undef;
Expand Down
21 changes: 10 additions & 11 deletions lib/Mojo/DOM/HTML.pm
Expand Up @@ -207,28 +207,28 @@ sub _render {
my ($self, $tree) = @_;

# Text (escaped)
my $e = $tree->[0];
return xml_escape $tree->[1] if $e eq 'text';
my $type = $tree->[0];
return xml_escape $tree->[1] if $type eq 'text';

# Raw text
return $tree->[1] if $e eq 'raw';
return $tree->[1] if $type eq 'raw';

# DOCTYPE
return '<!DOCTYPE' . $tree->[1] . '>' if $e eq 'doctype';
return '<!DOCTYPE' . $tree->[1] . '>' if $type eq 'doctype';

# Comment
return '<!--' . $tree->[1] . '-->' if $e eq 'comment';
return '<!--' . $tree->[1] . '-->' if $type eq 'comment';

# CDATA
return '<![CDATA[' . $tree->[1] . ']]>' if $e eq 'cdata';
return '<![CDATA[' . $tree->[1] . ']]>' if $type eq 'cdata';

# Processing instruction
return '<?' . $tree->[1] . '?>' if $e eq 'pi';
return '<?' . $tree->[1] . '?>' if $type eq 'pi';

# Start tag
my $start = 1;
my $content = '';
if ($e eq 'tag') {
if ($type eq 'tag') {
$start = 4;

# Open tag
Expand All @@ -246,8 +246,7 @@ sub _render {
# Key and value
push @attrs, qq{$key="} . xml_escape($value) . '"';
}
my $attrs = join ' ', @attrs;
$content .= " $attrs" if $attrs;
$content .= join ' ', '', @attrs if @attrs;

# Element without end tag
return $self->xml || $VOID{$tag} ? "$content />" : "$content></$tag>"
Expand All @@ -261,7 +260,7 @@ sub _render {
$content .= $self->_render($tree->[$_]) for $start .. $#$tree;

# End tag
$content .= '</' . $tree->[1] . '>' if $e eq 'tag';
$content .= '</' . $tree->[1] . '>' if $type eq 'tag';

return $content;
}
Expand Down

0 comments on commit ac79e79

Please sign in to comment.