function domInsert(element, parentElement, afterElement) {
      // if for some reason the previous element was removed
      // from the dom sometime before this code runs then let's
      // just stick to using the parent element as the anchor
      if (afterElement) {
        var afterNode = extractElementNode(afterElement);
        if (afterNode && !afterNode.parentNode && !afterNode.previousElementSibling) {
          afterElement = null;
        }
      }
      afterElement ? afterElement.after(element) : parentElement.prepend(element);
    }
@ngdoc method
@name $animateProvider#classNameFilter

@description
Sets and/or returns the CSS class regular expression that is checked when performing
an animation. Upon bootstrap the classNameFilter value is not set at all and will
therefore enable $animate to attempt to perform an animation on any element that is triggered.
When setting the `classNameFilter` value, animations will only be performed on elements
that successfully match the filter expression. This in turn can boost performance
for low-powered devices as well as applications containing a lot of structural operations.
@param {RegExp=} expression The className expression which will be checked against all animations
@return {RegExp} The current CSS className expression value. If null then there is no expression value