Move element recursion handling into a method.

This makes it easier to disable later on in the streaming parser.
This commit is contained in:
Yorick Peterse 2014-04-28 10:25:05 +02:00
parent 785ec26fe7
commit fd5bbbc9a2
1 changed files with 14 additions and 6 deletions

View File

@ -103,12 +103,7 @@ rule
element
: element_start expressions T_ELEM_END
{
element = val[0]
element.children = val[1] ? val[1].flatten : []
link_children(element)
element
on_element_children(val[0], val[1] ? val[1].flatten : [])
}
;
@ -333,6 +328,19 @@ Unexpected #{name} with value #{value.inspect} on line #{@line}:
return element
end
##
# @param [Oga::XML::Element] element
# @param [Array] children
# @return [Oga::XML::Element]
#
def on_element_children(element, children = [])
element.children = children
link_children(element)
return element
end
##
# @param [Array] pairs
# @return [Hash]