if n.type is TYPE_TEXT
i = 0
while i < n.text.length # don't foreach, cb might remove chars
- removed = cb n, i
- unless removed
+ advance = cb n, i
+ if advance
i += 1
if n.type is TYPE_TAG
block = is_display_block n.el
next = n
next_i = i
next_px = null
+ advance = true
if cur?
removed = operate()
+ # don't advance (to the next character next time) if we removed a
+ # character from the same text node as ``next``, because doing so
+ # renumbers the indexes in that string
+ if removed and cur is next
+ advance = false
else
removed = false
unless removed
cur = next
cur_i = next_i
cur_px = next_px
- return removed
+ return advance
queue null
iterate tree, queue
queue null