Skip to content

Commit

Permalink
adding in logic to detect when a node is not resolved - in which case…
Browse files Browse the repository at this point in the history
… we don't want to process the code block that was intended for the unfound node.
  • Loading branch information
bplawler committed Jun 11, 2012
1 parent e1f2ac4 commit 7f77966
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/main/scala/CrawlerDsl.scala
Expand Up @@ -360,12 +360,17 @@ abstract class Crawler(version: BrowserVersion = BrowserVersion.FIREFOX_3_6,
* by that ElementProcessor.
*/
private def processBlock(processor: ElementProcessor)(block: => Unit) = {
nodeStack.length match {
case 0 => push(processor.resolveNode(null))
case _ => push(processor.resolveNode(nodeStack(0)))
// attempt to resolve the node,
(
nodeStack.length match {
case 0 => processor.resolveNode(null)
case _ => processor.resolveNode(nodeStack(0))
}
// then process the block. If no node is resolved, skip the block.
) match {
case null =>
case n: DomNode => push(n); block; pop
}
block
pop
}

/**
Expand Down

0 comments on commit 7f77966

Please sign in to comment.