4935 |
## NOTE: Most of this code is copied from |parse_string| |
## NOTE: Most of this code is copied from |parse_string| |
4936 |
|
|
4937 |
## Step 1 # MUST |
## Step 1 # MUST |
4938 |
my $doc = $node->owner_document->implementation->create_document; |
my $this_doc = $node->owner_document; |
4939 |
|
my $doc = $this_doc->implementation->create_document; |
4940 |
## TODO: Mark as HTML document |
## TODO: Mark as HTML document |
4941 |
my $p = $class->new; |
my $p = $class->new; |
4942 |
$p->{document} = $doc; |
$p->{document} = $doc; |
4947 |
my $column = 0; |
my $column = 0; |
4948 |
$p->{set_next_input_character} = sub { |
$p->{set_next_input_character} = sub { |
4949 |
my $self = shift; |
my $self = shift; |
4950 |
|
|
4951 |
|
pop @{$self->{prev_input_character}}; |
4952 |
|
unshift @{$self->{prev_input_character}}, $self->{next_input_character}; |
4953 |
|
|
4954 |
$self->{next_input_character} = -1 and return if $i >= length $$s; |
$self->{next_input_character} = -1 and return if $i >= length $$s; |
4955 |
$self->{next_input_character} = ord substr $$s, $i++, 1; |
$self->{next_input_character} = ord substr $$s, $i++, 1; |
4956 |
$column++; |
$column++; |
4967 |
# |
# |
4968 |
} else { |
} else { |
4969 |
push @{$self->{char}}, $next_char; |
push @{$self->{char}}, $next_char; |
4970 |
|
## TODO: This is incorrect, since $next_char might be e.g. CR. |
4971 |
} |
} |
4972 |
} |
} |
4973 |
$self->{next_input_character} = 0x000A; # LF # MUST |
$self->{next_input_character} = 0x000A; # LF # MUST |
4976 |
} elsif ($self->{next_input_character} > 0x10FFFF) { |
} elsif ($self->{next_input_character} > 0x10FFFF) { |
4977 |
$self->{next_input_character} = 0xFFFD; # REPLACEMENT CHARACTER # MUST |
$self->{next_input_character} = 0xFFFD; # REPLACEMENT CHARACTER # MUST |
4978 |
} elsif ($self->{next_input_character} == 0x0000) { # NULL |
} elsif ($self->{next_input_character} == 0x0000) { # NULL |
4979 |
|
!!!parse-error (type => 'NULL'); |
4980 |
$self->{next_input_character} = 0xFFFD; # REPLACEMENT CHARACTER # MUST |
$self->{next_input_character} = 0xFFFD; # REPLACEMENT CHARACTER # MUST |
4981 |
} |
} |
4982 |
}; |
}; |
4983 |
|
$p->{prev_input_character} = [-1, -1, -1]; |
4984 |
|
$p->{next_input_character} = -1; |
4985 |
|
|
4986 |
my $ponerror = $onerror || sub { |
my $ponerror = $onerror || sub { |
4987 |
my (%opt) = @_; |
my (%opt) = @_; |
5060 |
## Step 12 # MUST |
## Step 12 # MUST |
5061 |
@cn = @{$root->child_nodes}; |
@cn = @{$root->child_nodes}; |
5062 |
for (@cn) { |
for (@cn) { |
5063 |
|
$this_doc->adopt_node ($_); |
5064 |
$node->append_child ($_); |
$node->append_child ($_); |
5065 |
} |
} |
5066 |
## ISSUE: adopt_node? mutation events? |
## ISSUE: mutation events? |
5067 |
|
|
5068 |
$p->_terminate_tree_constructor; |
$p->_terminate_tree_constructor; |
5069 |
} else { |
} else { |