diff options
| author | Dhruv Manek | 2011-10-21 17:53:37 -0700 |
|---|---|---|
| committer | Igor Minar | 2011-10-24 23:28:36 -0700 |
| commit | 163c799effd5cfadc57990f4d4127651bae3fbdb (patch) | |
| tree | fada61b2b9be00609fbf1e9cf903e2a48cf3a0fb | |
| parent | 7da70af1aefe8a147053a6a8b0890ede4245b68a (diff) | |
| download | angular.js-163c799effd5cfadc57990f4d4127651bae3fbdb.tar.bz2 | |
fix(angular.widget): Allow widgets to be styled in IE8 and below
Closes #584
| -rw-r--r-- | regression/issue-584.html | 24 | ||||
| -rw-r--r-- | src/Angular.js | 18 |
2 files changed, 41 insertions, 1 deletions
diff --git a/regression/issue-584.html b/regression/issue-584.html new file mode 100644 index 00000000..84e5e732 --- /dev/null +++ b/regression/issue-584.html @@ -0,0 +1,24 @@ +<!DOCTYPE html> +<html xmlns:ng="http://angularjs.org" xmlns:my="http://mynamespace.org"> + <head> + <style> + my\:time {color:#00f;display:block;border:1px solid #ccc;background-color:#ddd;} + </style> + <script src="../build/angular.js" ng:autobind></script> + <script> + angular.widget('my:time', function(compileElement){ + compileElement.css('display', 'block'); + return function(linkElement) { + function update() { + linkElement.text('Current time is: ' + new Date()); + setTimeout(update, 1000); + } + update(); + }; + }); + </script> + </head> + <body> + <my:time></my:time> + </body> +</html> diff --git a/src/Angular.js b/src/Angular.js index 9b651fce..256a119c 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -51,6 +51,22 @@ if ('i' !== 'I'.toLowerCase()) { function fromCharCode(code) { return String.fromCharCode(code); } +/** + * Creates the element for IE8 and below to allow styling of widgets + * (http://ejohn.org/blog/html5-shiv/). This hack works only if angular is + * included synchronously at the top of the document before IE sees any + * unknown elements. See regression/issue-584.html. + * + * @param {string} elementName Name of the widget. + * @returns {string} Lowercased string. + */ +function shivForIE(elementName) { + elementName = lowercase(elementName); + if (msie < 9 && elementName.charAt(0) != '@') { // ignore attr-widgets + document.createElement(elementName); + } + return elementName; +} var _undefined = undefined, _null = null, @@ -91,7 +107,7 @@ var _undefined = undefined, /** @name angular.directive */ angularDirective = extensionMap(angular, 'directive'), /** @name angular.widget */ - angularWidget = extensionMap(angular, 'widget', lowercase), + angularWidget = extensionMap(angular, 'widget', shivForIE), /** @name angular.filter */ angularFilter = extensionMap(angular, 'filter'), /** @name angular.service */ |
