diff options
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, |
