dom.pattern.Matcher Extends
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.

Inheritance

Constructor

goog.dom.pattern.Matcher()

Instance Methods

Public Protected Private
addPattern(patterncallback)
Adds a pattern to be matched. The callback can return an object whose keys are processing instructions.
Arguments:
pattern : goog.dom.pattern.AbstractPattern
The pattern to add.
callback : Function
Function to call when a match is found. Uses the above semantics.
code »
match(node)
Match the set of patterns against a match tree.
Arguments:
node : Node
The root node of the tree to match.
code »
matchToken_(position) boolean
Test the given node against all patterns.
Arguments:
position : goog.dom.TagIterator
A position in a node walk that is located at the token to process.
Returns: boolean  Whether a pattern modified the position or tree and its callback resulted in DOM structure or position modification.
code »
reset_()
Resets all the patterns.
code »

Instance Properties

callbacks_ :
Array of callbacks to call when a pattern is matched. The indexing is the same as the #patterns_ array.
Code »
patterns_ :
Array of patterns to attempt to match in parallel.
Code »

Package dom.pattern

Package Reference