Repository: angular/angular.js
File: src/ng/directive/input.js (JavaScript)

Code before:
  function minChange(val) {
    if (isDefined(val) && !isNumber(val)) {
      val = parseFloat(val);
    }
    minVal = isNumber(val) && !isNaN(val) ? val : 0;
    // ignore changes before model is initialized
    if (isNumber(ctrl.$modelValue) && isNaN(ctrl.$modelValue)) {
      return;
    }

    if (supportsRange && minAttrType === 'min') {
      var elVal = element.val();
      // IE11 doesn't set the el val correctly if the minVal is greater than the element value
      if (minVal > elVal) {
        element.val(minVal);
        elVal = minVal;
      }
      ctrl.$setViewValue(elVal);
    } else {
      // TODO(matsko): implement validateLater to reduce number of validations
      ctrl.$validate();
    }
  }

  function maxChange(val) {
    if (isDefined(val) && !isNumber(val)) {
      val = parseFloat(val);
    }
    maxVal = isNumber(val) && !isNaN(val) ? val : 100;
    // ignore changes before model is initialized
    if (isNumber(ctrl.$modelValue) && isNaN(ctrl.$modelValue)) {
      return;
    }

    if (supportsRange && maxAttrType === 'max') {
      var elVal = element.val();
      // IE11 doesn't set the el val correctly if the maxVal is greater than the element value
      if (maxVal < elVal) {
        element.val(maxVal);
        // IE11 and Chrome don't set the value to the minVal when max < min
        elVal = maxVal < minVal ? minVal : maxVal;
      }
      ctrl.$setViewValue(elVal);
    } else {
      // TODO(matsko): implement validateLater to reduce number of validations
      ctrl.$validate();
    }
  }

}


Review comment (suggestion):
Shouldn't this be reflected to `element.val()` then? I would expect something like:

``` js
if (maxVal < elVal) {
  elVal = Math.max(minVal, maxVal);
  element.val(elVal);
}
```


Code after:
        element.val(elVal);
      }
      ctrl.$setViewValue(elVal);
    } else {
      // TODO(matsko): implement validateLater to reduce number of validations
      ctrl.$validate();
    }
  }

  function maxChange(val) {
    if (isDefined(val) && !isNumber(val)) {
      val = parseFloat(val);
    }
    maxVal = isNumber(val) && !isNaN(val) ? val : undefined;
    // ignore changes before model is initialized
    if (isNumber(ctrl.$modelValue) && isNaN(ctrl.$modelValue)) {
      return;
    }

    if (supportsRange) {
      var elVal = element.val();
      // IE11 doesn't set the el val correctly if the maxVal is less than the element value
      if (maxVal < elVal) {
        element.val(maxVal);
        // IE11 and Chrome don't set the value to the minVal when max < min
        elVal = maxVal < minVal ? minVal : maxVal;
      }
      ctrl.$setViewValue(elVal);
    } else {
      // TODO(matsko): implement validateLater to reduce number of validations
      ctrl.$validate();
    }
  }

}

function urlInputType(scope, element, attr, ctrl, $sniffer, $browser) {
  // Note: no badInputChecker here by purpose as `url` is only a validation
  // in browsers, i.e. we can always read out input.value even if it is not valid!
  baseInputType(scope, element, attr, ctrl, $sniffer, $browser);
  stringBasedInputType(ctrl);

  ctrl.$$parserName = 'url';
  ctrl.$validators.url = function(modelValue, viewValue) {
    var value = modelValue || viewValue;
    return ctrl.$isEmpty(value) || URL_REGEXP.test(value);
  };
}

function emailInputType(scope, element, attr, ctrl, $sniffer, $browser) {
  // Note: no badInputChecker here by purpose as `url` is only a validation