示例#1
0
  public Selector directJoin(Selector firstI, Selector secondI) {
    // if both of them are null, something is very wrong
    if (secondI == null) return firstI.clone();

    if (firstI == null) return secondI.clone();

    Selector first = firstI.clone();
    List<SelectorPart> secondParts = ArraysUtils.deeplyClonedList(secondI.getParts());
    List<Extend> secondExtends = ArraysUtils.deeplyClonedList(secondI.getExtend());
    SelectorPart secondHead = secondParts.get(0);

    if (secondHead.isAppender())
      return indirectJoinNoClone(
          first, secondHead.getLeadingCombinator(), secondParts, secondExtends);

    /*
     * FIXME: test on old whether survives if first is not simple selector. (say, if:
     * (~"escaped") {
     *   &:pseudo() {
     *   }
     * }
     *
     */
    SelectorPart attachToHead = first.getLastPart();
    directlyJoinParts(attachToHead, secondHead);

    secondParts.remove(0);
    SelectorCombinator leadingCombinator =
        secondParts.isEmpty() ? null : secondParts.get(0).getLeadingCombinator();
    return indirectJoinNoClone(first, leadingCombinator, secondParts, secondExtends);
  }
示例#2
0
 public Selector indirectJoinNoClone(
     Selector first, SelectorCombinator combinator, Selector second) {
   return indirectJoinNoClone(first, combinator, second.getParts(), second.getExtend());
 }