abstractpattern.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright 2007 The Closure Library Authors. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS-IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. /**
  15. * @fileoverview DOM pattern base class.
  16. *
  17. * @author robbyw@google.com (Robby Walker)
  18. */
  19. goog.provide('goog.dom.pattern.AbstractPattern');
  20. goog.require('goog.dom.pattern.MatchType');
  21. /**
  22. * Base pattern class for DOM matching.
  23. *
  24. * @constructor
  25. */
  26. goog.dom.pattern.AbstractPattern = function() {
  27. /**
  28. * The first node matched by this pattern.
  29. * @type {Node}
  30. */
  31. this.matchedNode = null;
  32. };
  33. /**
  34. * Reset any internal state this pattern keeps.
  35. */
  36. goog.dom.pattern.AbstractPattern.prototype.reset = function() {
  37. // The base implementation does nothing.
  38. };
  39. /**
  40. * Test whether this pattern matches the given token.
  41. *
  42. * @param {Node} token Token to match against.
  43. * @param {goog.dom.TagWalkType} type The type of token.
  44. * @return {goog.dom.pattern.MatchType} {@code MATCH} if the pattern matches.
  45. */
  46. goog.dom.pattern.AbstractPattern.prototype.matchToken = function(token, type) {
  47. return goog.dom.pattern.MatchType.NO_MATCH;
  48. };