diff options
| author | Misko Hevery | 2011-02-03 16:35:51 -0800 | 
|---|---|---|
| committer | Misko Hevery | 2011-02-04 13:44:22 -0800 | 
| commit | 46d690ff0188836688811dda9af1b99c44750c48 (patch) | |
| tree | f2253031ba3c8574ec93f03a18bb9fb2667aef51 /src/markups.js | |
| parent | 882f412d578e4f01394847fa5fde21b6b4096de2 (diff) | |
| download | angular.js-46d690ff0188836688811dda9af1b99c44750c48.tar.bz2 | |
smarter normalization of value on option, and htmlParser fixes
Diffstat (limited to 'src/markups.js')
| -rw-r--r-- | src/markups.js | 33 | 
1 files changed, 19 insertions, 14 deletions
| diff --git a/src/markups.js b/src/markups.js index 0aa7170e..89cc0d05 100644 --- a/src/markups.js +++ b/src/markups.js @@ -57,21 +57,26 @@ angularTextMarkup('{{}}', function(text, textNode, parentElement) {    }  }); -// TODO: this should be widget not a markup -angularTextMarkup('OPTION', function(text, textNode, parentElement){ -  if (nodeName_(parentElement) == "OPTION") { -    var select = jqLite('<select>'); -    select.append(parentElement.clone()); -    htmlParser(select.html(), { -      start: function(tag, attrs) { -        if (isUndefined(attrs.value)) { -          parentElement.attr('value', text); +/** + * This tries to normalize the behavior of value attribute across browsers. If value attribute is + * not specified, then specify it to be that of the text. + */ +angularTextMarkup('option', function(text, textNode, parentElement){ +  if (lowercase(nodeName_(parentElement)) == 'option') { +    if (msie <= 7) { +      // In IE7 The issue is that there is no way to see if the value was specified hence +      // we have to resort to parsing HTML; +      htmlParser(parentElement[0].outerHTML, { +        start: function(tag, attrs) { +          if (isUndefined(attrs.value)) { +            parentElement.attr('value', text); +          }          } -      }, -      chars: noop, -      end: noop, -      comment: noop -    }); +      }); +    } else if (parentElement[0].getAttribute('value') == null) { +      // jQuery does normalization on 'value' so we have to bypass it. +      parentElement.attr('value', text); +    }    }  }); | 
