anchor.diff:    List<ComplexSelector> _extendCompound(CompoundSelector compound,
         Map<SimpleSelector, Set<ExtendSource>> extensions,
         {bool replace: false}) {
  -    var changed = false;
  +    var original = compound;
  +
       List<ComplexSelector> extended;
       for (var i = 0; i < compound.components.length; i++) {
         var simple = compound.components[i];
   
  -      // TODO: handle extending into pseudo selectors
  +      var extendedPseudo = simple is PseudoSelector && simple.selector != null
  +          ? _extendPseudo(simple, extensions, replace: replace)
  +          : null;
  +
  +      if (extendedPseudo != null) {
  +        var simples = new List<SimpleSelector>(
  +            compound.components.length - 1 + extendedPseudo.length);
  +        simples.setRange(0, i, compound.components);
  +        simples.setRange(i, i + extendedPseudo.length, extendedPseudo);
  +        simples.setRange(
  +            i + extendedPseudo.length, simples.length, compound.components, i);
  +        original = new CompoundSelector(simples);
  +      }
   
         var sources = extensions[simple];
         if (sources == null) continue;
   
  -      var compoundWithoutSimple = compound.components.toList()..removeAt(i);
  +      var compoundWithoutSimple =
  +          new List<SimpleSelector>(compound.components.length - 1);
  +      compoundWithoutSimple.setRange(0, i, compound.components);
  +      compoundWithoutSimple.setRange(
  +          i, compound.components.length - 1, compound.components, i);
         for (var source in sources) {
           for (var complex in source.extender.components) {
             var extenderBase = complex.components.last as CompoundSelector;
  
positive.code:     }
  
      if (_extensions.isNotEmpty) {
        selector = _extendList(selector, _extensions);
        selectorValue = new CssValue(selector, selectorValue.span);
      }
      var rule = new CssStyleRule(selectorValue, span);
  
      for (var complex in selector.components) {
        for (var component in complex.components) {
          if (component is CompoundSelector) {
            for (var simple in component.components) {
              _selectors.putIfAbsent(simple, () => new Set()).add(rule);
            }
          }
        }
      }
  
      return rule;
    }
  
    void addExtension(
  
negative.code:       }
      }
  
      if (extended == null) {
        return identical(original, compound)
            ? null
            : [
                new ComplexSelector([original])
              ];
      } else if (!identical(original, compound)) {
        if (replace) {
          extended.insert(0, new ComplexSelector([original]));
        } else {
          extended[0] = new ComplexSelector([original]);
        }
      }
  
      return extended;
    }
  
    List<PseudoSelector> _extendPseudo(
        PseudoSelector pseudo, Map<SimpleSelector, Set<ExtendSource>> extensions,
        {bool replace: false}) {
      // TODO: avoid recursive loops when extending.
      var extended = _extendList(pseudo.selector, extensions, replace: replace);
      if (extended == null) return null;
  
      // TODO: what do we do about placeholders in the selector? If we just
      // eliminate them here, what happens to future extends?
  
      // For `:not()`, we usually want to get rid of any complex selectors because
      // that will cause the selector to fail to parse on all browsers at time of
      // writing. We can keep them if either the original selector had a complex
      // selector, or the result of extending has only complex selectors, because
      // either way we aren't breaking anything that isn't already broken.
      Iterable<ComplexSelector> complexes = extended.components;
      if (pseudo.normalizedName == "not" &&
          !pseudo.selector.components
              .any((complex) => complex.components.length > 1) &&
          extended.components.any((complex) => complex.components.length == 1)) {
        complexes = extended.components
            .where((complex) => complex.components.length <= 1);
      }
  
      complexes = complexes.expand((complex) {
        if (complex.components.length != 1) return [complex];
        if (complex.components.first is! CompoundSelector) return [complex];
        var compound = complex.components.first as CompoundSelector;
        if (compound.components.length != 1) return [complex];
        if (compound.components.first is! PseudoSelector) return [complex];
        var innerPseudo = compound.components.first as PseudoSelector;
        if (innerPseudo.selector == null) return [complex];
  
        switch (pseudo.normalizedName) {
          case 'not':
            // In theory, if there's a `:not` nested within another `:not`, the
            // inner `:not`'s contents should be unified with the return value.
            // For example, if `:not(.foo)` extends `.bar`, `:not(.bar)` should
            // become `.foo:not(.bar)`. However, this is a narrow edge case and
            // supporting it properly would make this code and the code calling it
            // a lot more complicated, so it's not supported for now.
            if (innerPseudo.normalizedName != 'matches') return [];
            return innerPseudo.selector.components;
  
          case 'matches':
          case 'any':
          case 'current':
          case 'nth-child':
          case 'nth-last-child':
            // As above, we could theoretically support :not within :matches, but
            // doing so would require this method and its callers to handle much
            // more complex cases that likely aren't worth the pain.
            if (innerPseudo.name != pseudo.name) return [];
            if (innerPseudo.argument != pseudo.argument) return [];
            return innerPseudo.selector.components;
  
          case 'has':
          case 'host':
          case 'host-context':
            // We can't expand nested selectors here, because each layer adds an
            // additional layer of semantics. For example, `:has(:has(img))`
            // doesn't match `<div><img></div>` but `:has(img)` does.
            return [complex];
  
          default:
            return [];
        }
      });
  
      // Older browsers support `:not`, but only with a single complex selector.
      // In order to support those browsers, we break up the contents of a `:not`
      // unless it originally contained a selector list.
      if (pseudo.normalizedName == 'not' &&
          pseudo.selector.components.length == 1) {
        return complexes
            .map((complex) => pseudo.withSelector(new SelectorList([complex])))
            .toList();
      } else {
        return [pseudo.withSelector(new SelectorList(complexes))];
      }
    }
  
    List<ComplexSelector> _trim(List<List<ComplexSelector>> lists) {
  