[ Index ]
 

Code source de PRADO 3.0.6

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/tests/test_tools/selenium/core/scripts/ -> find_matching_child.js (source)

   1  /*
   2   * Copyright 2004 ThoughtWorks, Inc
   3   *
   4   *  Licensed under the Apache License, Version 2.0 (the "License");
   5   *  you may not use this file except in compliance with the License.
   6   *  You may obtain a copy of the License at
   7   *
   8   *      http://www.apache.org/licenses/LICENSE-2.0
   9   *
  10   *  Unless required by applicable law or agreed to in writing, software
  11   *  distributed under the License is distributed on an "AS IS" BASIS,
  12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13   *  See the License for the specific language governing permissions and
  14   *  limitations under the License.
  15   *
  16   */
  17  
  18  Element.findMatchingChildren = function(element, selector) {
  19    var matches = $A([]);
  20  
  21    var childCount = element.childNodes.length;
  22    for (var i=0; i<childCount; i++) {
  23      var child = element.childNodes[i];
  24      if (selector(child)) {
  25        matches.push(child);
  26      } else {
  27        childMatches = Element.findMatchingChildren(child, selector);
  28        matches.push(childMatches);
  29      }
  30    }
  31  
  32    return matches.flatten();
  33  }
  34  
  35  ELEMENT_NODE_TYPE = 1;
  36  
  37  Element.findFirstMatchingChild = function(element, selector) {
  38  
  39    var childCount = element.childNodes.length;
  40    for (var i=0; i<childCount; i++) {
  41      var child = element.childNodes[i];
  42      if (child.nodeType == ELEMENT_NODE_TYPE) {
  43        if (selector(child)) {
  44          return child;
  45        }
  46        result = Element.findFirstMatchingChild(child, selector);
  47        if (result) {
  48          return result;
  49        }
  50      }
  51    }
  52    return null;
  53  }
  54  
  55  Element.findFirstMatchingParent = function(element, selector) {
  56    var current = element.parentNode;
  57    while (current != null) {
  58      if (selector(current)) {
  59        break;
  60      }
  61      current = current.parentNode;
  62    }
  63    return current;
  64  }
  65  
  66  Element.findMatchingChildById = function(element, id) {
  67    return Element.findFirstMatchingChild(element, function(element){return element.id==id} );
  68  }
  69  


Généré le : Sun Feb 25 21:07:04 2007 par Balluche grâce à PHPXref 0.7