@@ -1567,10 +1567,8 @@ function rangeInputType(scope, element, attr, ctrl, $sniffer, $browser) {
1567
1567
1568
1568
if ( minAttrType ) {
1569
1569
ctrl . $validators . min = minAttrType === 'min' && supportsRange ?
1570
- function noopMinValidator ( ) {
1571
- // Since all browsers set the input to a valid value, we don't need to check validity
1572
- return true ;
1573
- } :
1570
+ // Since all browsers set the input to a valid value, we don't need to check validity
1571
+ function noopMinValidator ( ) { return true ; } :
1574
1572
// ngMin doesn't set the min attr, so the browser doesn't adjust the input value as setting min would
1575
1573
function minValidator ( modelValue , viewValue ) {
1576
1574
return ctrl . $isEmpty ( viewValue ) || isUndefined ( minVal ) || viewValue >= minVal ;
@@ -1581,10 +1579,8 @@ function rangeInputType(scope, element, attr, ctrl, $sniffer, $browser) {
1581
1579
1582
1580
if ( maxAttrType ) {
1583
1581
ctrl . $validators . max = maxAttrType === 'max' && supportsRange ?
1584
- function noopMaxValidator ( ) {
1585
- // Since all browsers set the input to a valid value, we don't need to check validity
1586
- return true ;
1587
- } :
1582
+ // Since all browsers set the input to a valid value, we don't need to check validity
1583
+ function noopMaxValidator ( ) { return true ; } :
1588
1584
// ngMax doesn't set the max attr, so the browser doesn't adjust the input value as setting max would
1589
1585
function maxValidator ( modelValue , viewValue ) {
1590
1586
return ctrl . $isEmpty ( viewValue ) || isUndefined ( maxVal ) || viewValue <= maxVal ;
@@ -1593,19 +1589,16 @@ function rangeInputType(scope, element, attr, ctrl, $sniffer, $browser) {
1593
1589
setInitialValueAndObserver ( maxAttrType , 'max' , maxChange ) ;
1594
1590
}
1595
1591
1596
- function setInitialValueAndObserver ( attrType , attrName , changeFn ) {
1597
- var initialAttrValue ;
1598
- if ( attrType === attrName ) {
1599
- initialAttrValue = attr [ attrName ] ;
1600
- // Set the actual element attribute so that the browser can adjust the value based on
1601
- // the max value, which might be interpolated
1602
- element . attr ( attrName , initialAttrValue ) ;
1592
+ function setInitialValueAndObserver ( actualAttrName , htmlAttrName , changeFn ) {
1593
+ // e.g. max === max
1594
+ if ( actualAttrName === htmlAttrName ) {
1595
+ // interpolated attributes set the attribute value only after a digest, but we need the
1596
+ // attribute value when the input is first rendered, so that the browser can adjust the
1597
+ // input value based on the min/max value
1598
+ element . attr ( htmlAttrName , attr [ htmlAttrName ] ) ;
1603
1599
}
1604
1600
1605
- // This initalizes the min/max value, so that non-support browsers validate with the correct
1606
- // values during the initial $render
1607
- changeFn ( initialAttrValue ) ;
1608
- attr . $observe ( attrName , changeFn ) ;
1601
+ attr . $observe ( htmlAttrName , changeFn ) ;
1609
1602
}
1610
1603
1611
1604
function minChange ( val ) {
0 commit comments