match method

int match(
  1. Selector other
)

Compares this Selector with the other Selector

Returns number of matched Selector elements if match. 0 means not match.

Implementation

int match(Selector other) {
  final otherElements = other.mixinElements();

  if (otherElements.isEmpty || elements.length < otherElements.length) {
    return 0;
  } else {
    for (var i = 0; i < otherElements.length; i++) {
      if (elements[i].value != otherElements[i]) return 0;
    }
  }
  return otherElements.length; // return number of matched elements

//3.0.0 20170528
// Selector.prototype.match = function (other) {
//     var elements = this.elements,
//         len = elements.length,
//         olen, i;
//
//     other = other.mixinElements();
//     olen = other.length;
//     if (olen === 0 || len < olen) {
//         return 0;
//     } else {
//         for (i = 0; i < olen; i++) {
//             if (elements[i].value !== other[i]) {
//                 return 0;
//             }
//         }
//     }
//
//     return olen; // return number of matched elements
// };
}