The goog.dom.pattern.Matcher Class

goog.dom.pattern.Matcher()

Given a set of patterns and a root node, this class tests the patterns in parallel. It is not (yet) a smart matcher - it doesn't do any advanced backtracking. Given the pattern DIV, SPAN the matcher will not match DIV, DIV, SPAN because it starts matching at the first DIV, fails to match SPAN at the second, and never backtracks to try again. It is also possible to have a set of complex patterns that when matched in parallel will miss some possible matches. Running multiple times will catch all matches eventually.

.addPattern(pattern, callback)

Adds a pattern to be matched. The callback can return an object whose keys are processing instructions.

pattern {goog.dom.pattern.AbstractPattern}
The pattern to add.
callback {Function}
Function to call when a match is found. Uses the above semantics.

.match(node)

Match the set of patterns against a match tree.

node {Node}
The root node of the tree to match.