Sha256: 7981c03f851cd16dd5d77e920f7cd139d9c08ff5371682715daa305188adce0a

Contents?: true

Size: 1.89 KB

Versions: 28

Compression:

Stored size: 1.89 KB

Contents

/*
 * Copyright 2004 ThoughtWorks, Inc
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 */

elementFindMatchingChildren = function(element, selector) {
  var matches = [];

  var childCount = element.childNodes.length;
  for (var i=0; i<childCount; i++) {
    var child = element.childNodes[i];
    if (selector(child)) {
      matches.push(child);
    } else {
      childMatches = elementFindMatchingChildren(child, selector);
      matches.push(childMatches);
    }
  }

  return matches.flatten();
}

ELEMENT_NODE_TYPE = 1;

elementFindFirstMatchingChild = function(element, selector) {

  var childCount = element.childNodes.length;
  for (var i=0; i<childCount; i++) {
    var child = element.childNodes[i];
    if (child.nodeType == ELEMENT_NODE_TYPE) {
      if (selector(child)) {
        return child;
      }
      result = elementFindFirstMatchingChild(child, selector);
      if (result) {
        return result;
      }
    }
  }
  return null;
}

elementFindFirstMatchingParent = function(element, selector) {
  var current = element.parentNode;
  while (current != null) {
    if (selector(current)) {
      break;
    }
    current = current.parentNode;
  }
  return current;
}

elementFindMatchingChildById = function(element, id) {
  return elementFindFirstMatchingChild(element, function(element){return element.id==id} );
}

Version data entries

28 entries across 28 versions & 5 rubygems

Version Path
zena-1.2.7 vendor/plugins/selenium-on-rails/selenium-core/scripts/find_matching_child.js
zena-1.2.6 vendor/plugins/selenium-on-rails/selenium-core/scripts/find_matching_child.js
zena-1.2.5 vendor/plugins/selenium-on-rails/selenium-core/scripts/find_matching_child.js
zena-1.2.4 vendor/plugins/selenium-on-rails/selenium-core/scripts/find_matching_child.js
zena-1.2.3 vendor/plugins/selenium-on-rails/selenium-core/scripts/find_matching_child.js
zena-1.2.2 vendor/plugins/selenium-on-rails/selenium-core/scripts/find_matching_child.js
zena-1.2.1 vendor/plugins/selenium-on-rails/selenium-core/scripts/find_matching_child.js
zena-1.2.0 vendor/plugins/selenium-on-rails/selenium-core/scripts/find_matching_child.js
browsercms-3.1.5 test/selenium-core/scripts/find_matching_child.js
selenium-core-runner-0.0.5 public/selenium-core-runner/scripts/find_matching_child.js
selenium-core-runner-0.0.4 public/selenium-core-runner/scripts/find_matching_child.js
selenium-core-runner-0.0.3 public/selenium-core-runner/scripts/find_matching_child.js
selenium-webdriver-0.0.24 common/src/js/core/scripts/find_matching_child.js
selenium-webdriver-0.0.23 common/src/js/core/scripts/find_matching_child.js
selenium-webdriver-0.0.22 common/src/js/core/scripts/find_matching_child.js
selenium-webdriver-0.0.21 common/src/js/core/scripts/find_matching_child.js
selenium-webdriver-0.0.20 common/src/js/core/scripts/find_matching_child.js
selenium-webdriver-0.0.19 common/src/js/core/scripts/find_matching_child.js
selenium-webdriver-0.0.18 common/src/js/core/scripts/find_matching_child.js
rainux-selenium-webdriver-0.0.17 common/src/js/core/scripts/find_matching_child.js