Compare nodes in on_path instead of indexes.
This saves some code and effectively does the same thing.
This commit is contained in:
parent
5808ffa7a4
commit
d6aec6aa16
|
@ -54,12 +54,12 @@ module Oga
|
|||
end
|
||||
|
||||
def on_path(node)
|
||||
last_index = node.children.length - 1
|
||||
last_node = node.children[-1]
|
||||
|
||||
node.children.each_with_index do |test, index|
|
||||
node.children.each do |test|
|
||||
process(test)
|
||||
|
||||
if index < last_index and !@stack.empty?
|
||||
if test != last_node and !@stack.empty?
|
||||
swap_context
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue