diff options
| author | Misko Hevery | 2011-02-03 12:25:51 -0800 | 
|---|---|---|
| committer | Misko Hevery | 2011-02-03 13:25:01 -0800 | 
| commit | b6a01bd27dbcd2f9c9df917ecc96b8a2bd88413d (patch) | |
| tree | 9ae08321a3741520014eac4d751a23ac39ab5f7e /src | |
| parent | aaaad298ac6447497b1b86edac5b0d9b092625a2 (diff) | |
| download | angular.js-b6a01bd27dbcd2f9c9df917ecc96b8a2bd88413d.tar.bz2 | |
fixed population of value attribute on option
The value attribute must be populated manually, since different
browsers default to different value of option when not explicitly
defined.
Diffstat (limited to 'src')
| -rw-r--r-- | src/markups.js | 17 | ||||
| -rw-r--r-- | src/sanitizer.js | 6 | 
2 files changed, 15 insertions, 8 deletions
diff --git a/src/markups.js b/src/markups.js index 21dab128..0aa7170e 100644 --- a/src/markups.js +++ b/src/markups.js @@ -60,11 +60,18 @@ 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 = document.createElement('select'); -    select.insertBefore(parentElement[0].cloneNode(true), _null); -    if (!select.innerHTML.match(/<option(\s.*\s|\s)value\s*=\s*.*>.*<\/\s*option\s*>/gi)) { -      parentElement.attr('value', text); -    } +    var select = jqLite('<select>'); +    select.append(parentElement.clone()); +    htmlParser(select.html(), { +      start: function(tag, attrs) { +        if (isUndefined(attrs.value)) { +          parentElement.attr('value', text); +        } +      }, +      chars: noop, +      end: noop, +      comment: noop +    });    }  }); diff --git a/src/sanitizer.js b/src/sanitizer.js index c8a7b9f1..8f4b87a6 100644 --- a/src/sanitizer.js +++ b/src/sanitizer.js @@ -15,9 +15,9 @@   */  // Regular Expressions for parsing tags and attributes -var START_TAG_REGEXP = /^<\s*([\w:]+)((?:\s+\w+(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)\s*>/, -  END_TAG_REGEXP = /^<\s*\/\s*([\w:]+)[^>]*>/, -  ATTR_REGEXP = /(\w+)(?:\s*=\s*(?:(?:"((?:[^"])*)")|(?:'((?:[^'])*)')|([^>\s]+)))?/g, +var START_TAG_REGEXP = /^<\s*([\w:-]+)((?:\s+[\w:-]+(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)\s*>/, +  END_TAG_REGEXP = /^<\s*\/\s*([\w:-]+)[^>]*>/, +  ATTR_REGEXP = /([\w:-]+)(?:\s*=\s*(?:(?:"((?:[^"])*)")|(?:'((?:[^'])*)')|([^>\s]+)))?/g,    BEGIN_TAG_REGEXP = /^</,    BEGING_END_TAGE_REGEXP = /^<\s*\//,    COMMENT_REGEXP = /<!--(.*?)-->/g,  | 
