docs: function upgradeElementInternal(element, optJsClass) {
      // Verify argument type.
      if (!(typeof element === 'object' && element instanceof Element)) {
        throw new Error('Invalid argument provided to upgrade MDL element.');
      }
      var upgradedList = getUpgradedListOfElement_(element);
      var classesToUpgrade = [];
      // If jsClass is not provided scan the registered components to find the
      // ones matching the element's CSS classList.
      if (!optJsClass) {
        var classList = element.classList;
        registeredComponents_.forEach(function(component) {
          // Match CSS & Not to be upgraded & Not upgraded.
          if (classList.contains(component.cssClass) &&
              classesToUpgrade.indexOf(component) === -1 &&
              !isElementUpgraded_(element, component.className)) {
            classesToUpgrade.push(component);
          }
        });
      } else if (!isElementUpgraded_(element, optJsClass)) {
        classesToUpgrade.push(findRegisteredClass_(optJsClass));
      }
  
      // Upgrade the element for each classes.
      for (var i = 0, n = classesToUpgrade.length, registeredClass; i < n; i++) {
        registeredClass = classesToUpgrade[i];
        if (registeredClass) {
          // Mark element as upgraded.
          upgradedList.push(registeredClass.className);
          element.setAttribute('data-upgraded', upgradedList.join(','));
          var instance = new registeredClass.classConstructor(element);
          instance[componentConfigProperty_] = registeredClass;
          createdComponents_.push(instance);
          // Call any callbacks the user has registered with this component type.
          for (var j = 0, m = registeredClass.callbacks.length; j < m; j++) {
            registeredClass.callbacks[j](element);
          }
  
          if (registeredClass.widget) {
            // Assign per element instance for control over API
            element[registeredClass.className] = instance;
          }
        } else {
          throw new Error(
            'Unable to find a registered component for the given class.');
        }
  
        var ev;
        if ('CustomEvent' in window && typeof window.CustomEvent === 'function') {
          ev = new CustomEvent('mdl-componentupgraded', {
            bubbles: true, cancelable: false
          });
        } else {
          ev = document.createEvent('Events');
          ev.initEvent('mdl-componentupgraded', true, true);
        }
        element.dispatchEvent(ev);
      }
    }