Skip to content

Commit

Permalink
more consistent order
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jul 16, 2014
1 parent 34c1438 commit fbbafd9
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions lib/Mojo/DOM/HTML.pm
Expand Up @@ -26,15 +26,15 @@ my $TOKEN_RE = qr/
(?:
<(?:
!(?:
--(.*?)--\s* # Comment
|
\[CDATA\[(.*?)\]\] # CDATA
|
DOCTYPE(
\s+\w+ # Doctype
(?:(?:\s+\w+)?(?:\s+(?:"[^"]*"|'[^']*'))+)? # External ID
(?:\s+\[.+?\])? # Int Subset
\s*)
|
--(.*?)--\s* # Comment
|
\[CDATA\[(.*?)\]\] # CDATA
)
|
\?(.*?)\? # Processing Instruction
Expand Down Expand Up @@ -106,7 +106,7 @@ sub parse {
my $xml = $self->xml;
my $current = my $tree = ['root'];
while ($html =~ m/\G$TOKEN_RE/gcso) {
my ($text, $comment, $cdata, $doctype, $pi, $tag, $runaway)
my ($text, $doctype, $comment, $cdata, $pi, $tag, $runaway)
= ($1, $2, $3, $4, $5, $6, $11);

# Text (and runaway "<")
Expand Down Expand Up @@ -203,9 +203,8 @@ sub _end {

sub _node {
my ($current, $type, $content) = @_;
my $new = [$type, $content, $current];
push @$current, my $new = [$type, $content, $current];
weaken $new->[2];
push @$current, $new;
}

sub _render {
Expand Down Expand Up @@ -246,7 +245,7 @@ sub _render {
push @attrs, $key and next unless defined(my $value = $tree->[2]{$key});

# Key and value
push @attrs, qq{$key="} . xml_escape($value) . '"';
push @attrs, $key . '="' . xml_escape($value) . '"';
}
$result .= join ' ', '', @attrs if @attrs;

Expand Down Expand Up @@ -294,9 +293,8 @@ sub _start {
}

# New tag
my $new = ['tag', $start, $attrs, $$current];
push @$$current, my $new = ['tag', $start, $attrs, $$current];
weaken $new->[3];
push @$$current, $new;
$$current = $new;
}

Expand Down

0 comments on commit fbbafd9

Please sign in to comment.