Changeset 1047


Ignore:
Timestamp:
10/02/08 21:24:11 (10 years ago)
Author:
douglas
Message:

FIXED Ticket #1286 Allow callbacks as selection criteria.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/XinhaCore.js

    r1046 r1047  
    42864286/** Traverses the DOM upwards and returns the first element that is of one of the specified types 
    42874287 *  @param {Selection} sel  Selection object as returned by getSelection 
    4288  *  @param {Array} types Array of HTML tag names (lower case) 
     4288 *  @param {Array} types Array of matching criteria.  Each criteria is either a string containing the tag name, or a callback used to select the element. 
    42894289 *  @returns {DomNode|null}  
    42904290 */ 
     
    43184318        return prnt; 
    43194319      } 
    4320       if ( types.contains(prnt.tagName.toLowerCase()) ) 
    4321       { 
     4320      for (var index=0; index<types.length; ++index) { 
     4321        if (typeof types[index] == 'string' && types[index] == prnt.tagName.toLowerCase()){ 
     4322          // Criteria is a tag name.  It matches 
    43224323        return prnt; 
    43234324      } 
     4325        else if (typeof types[index] == 'function' && types[index](this, prnt)) { 
     4326          // Criteria is a callback.  It matches 
     4327          return prnt; 
     4328        } 
     4329      } 
     4330 
    43244331      if ( prnt.tagName.toLowerCase() == 'body' ) 
    43254332      { 
Note: See TracChangeset for help on using the changeset viewer.