function filterByAttribute(selectorInitializer, attribute, options) {
  const opts = new Options(options, { defaults: { isNot: false } });
  const { isNot } = opts;

  let attrName = attribute;
  let attrValue = null;

  if (_.isArray(attribute)) {
    [attrName, attrValue] = attribute;
  }

  if (!utils.isNonBlankString(attrName)) {
    throw new TypeError(
      `Attribute name must be a non-blank string but it is ${typeOf(attrName)} (${attrName})`
    );
  }

  return Selector(selectorInitializer).filter(
    (node) => {
      if (!node.hasAttribute(attrName)) {
        return !!isNot;
      }

      if (attrValue === void(0) || attrValue === null) {
        return !isNot;
      }

      const attr = node.getAttribute(attrName);

      // When attribute value is `RegExp` we use match otherwise we use string equality.
      if (attrValue.test && attrValue.exec && (attrValue.ignoreCase || attrValue.ignoreCase === false)) {
        const matches = attrValue.test(attr);
        return isNot ? !matches : matches;
      }
      else {
        return isNot ? (attr !== (attrValue + '')) : (attr === (attrValue + ''));
      }
    }, { attrName, attrValue, isNot } // dependencies
  );
}
/**
 * Accepts TestCafe selector initializer and creates new selector filtered by
 * attribute.
 *
 * @param {*} selectorInitializer - Anything that TestCafe accepts as its `Selector` initializer
 * @param {string[]|string} attribute - Attribute to filter by. Must be an array where first element is an attribute name, which must be a non-blank string, and second is optional attribute value. When it's a nil then selector would be filtered by existence of attribute. When it's a regular expression then selector would be filtered by matching its value to that regular expression. Otherwise selector would be filtered by strict equality of attribute value to stringified version of that value. When attribute has no value (a nil value) then just string of attribute name can be passed instead. Examples: ['foo', /.*bar$/], ['cid', 1], ['disabled'], 'disabled
 * @param {Options} [options] - Options
 * @param {boolean} [options.isNot=false] - When `true` then filter condition would be negated, for example, calling it with 'value', 123, `false` would return selector with only DOM nodes that doesn't have 'value' attribute with value equal '123'
 * @returns {Selector}
 */
Accepts TestCafe selector initializer and creates new selector filtered by
attribute.

@param {*} selectorInitializer - Anything that TestCafe accepts as its `Selector` initializer
@param {string[]|string} attribute - Attribute to filter by. Must be an array where first element is an attribute name, which must be a non-blank string, and second is optional attribute value. When it's a nil then selector would be filtered by existence of attribute. When it's a regular expression then selector would be filtered by matching its value to that regular expression. Otherwise selector would be filtered by strict equality of attribute value to stringified version of that value. When attribute has no value (a nil value) then just string of attribute name can be passed instead.
Accepts TestCafe selector initializer and creates new selector filtered by attribute . @param { * } selectorInitializer - Anything that TestCafe accepts as its ` Selector ` initializer @param { string [] |string } attribute - Attribute to filter by . Must be an array where first element is an attribute name which must be a non - blank string and second is optional attribute value . When it ' s a nil then selector would be filtered by existence of attribute . When it ' s a regular expression then selector would be filtered by matching its value to that regular expression . Otherwise selector would be filtered by strict equality of attribute value to stringified version of that value . When attribute has no value ( a nil value ) then just string of attribute name can be passed instead .
function filterByAttribute(selectorInitializer, attribute, options) {
  const opts = new Options(options, { defaults: { isNot: false } });
  const { isNot } = opts;
  let attrName = attribute;
  let attrValue = null;
  if (_.isArray(attribute)) {
    [attrName, attrValue] = attribute;
  }
  if (!utils.isNonBlankString(attrName)) {
    throw new TypeError(
      `Attribute name must be a non-blank string but it is ${typeOf(attrName)} (${attrName})`
    );
  }
  return Selector(selectorInitializer).filter(
    (node) => {
      if (!node.hasAttribute(attrName)) {
        return !!isNot;
      }
      if (attrValue === void(0) || attrValue === null) {
        return !isNot;
      }
      const attr = node.getAttribute(attrName);
      if (attrValue.test && attrValue.exec && (attrValue.ignoreCase || attrValue.ignoreCase === false)) {
        const matches = attrValue.test(attr);
        return isNot ? !matches : matches;
      }
      else {
        return isNot ? (attr !== (attrValue + '')) : (attr === (attrValue + ''));
      }
    }, { attrName, attrValue, isNot } 
  );
}
function filterByAttribute ( selectorInitializer , attribute , options ) { const opts = new Options ( options , { defaults : { isNot : false } } ) ; const { isNot } = opts ; let attrName = attribute ; let attrValue = null ; if ( _ . isArray ( attribute ) ) { [ attrName , attrValue ] = attribute ; } if ( ! utils . isNonBlankString ( attrName ) ) { throw new TypeError ( ` ${ typeOf ( attrName ) } ${ attrName } ` ) ; } return Selector ( selectorInitializer ) . filter ( ( node ) => { if ( ! node . hasAttribute ( attrName ) ) { return ! ! isNot ; } if ( attrValue === void ( 0 ) || attrValue === null ) { return ! isNot ; } const attr = node . getAttribute ( attrName ) ; if ( attrValue . test && attrValue . exec && ( attrValue . ignoreCase || attrValue . ignoreCase === false ) ) { const matches = attrValue . test ( attr ) ; return isNot ? ! matches : matches ; } else { return isNot ? ( attr !== ( attrValue + '' ) ) : ( attr === ( attrValue + '' ) ) ; } } , { attrName , attrValue , isNot } ) ; }
Accepts TestCafe selector initializer and creates new selector filtered by
 attribute.
Accepts TestCafe selector initializer and creates new selector filtered by attribute .
// When attribute value is `RegExp` we use match otherwise we use string equality. // dependencies