From 163c799effd5cfadc57990f4d4127651bae3fbdb Mon Sep 17 00:00:00 2001 From: Dhruv Manek Date: Fri, 21 Oct 2011 17:53:37 -0700 Subject: [PATCH] fix(angular.widget): Allow widgets to be styled in IE8 and below Closes #584 --- regression/issue-584.html | 24 ++++++++++++++++++++++++ src/Angular.js | 18 +++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 regression/issue-584.html diff --git a/regression/issue-584.html b/regression/issue-584.html new file mode 100644 index 000000000000..84e5e732c356 --- /dev/null +++ b/regression/issue-584.html @@ -0,0 +1,24 @@ + + + + + + + + + + + diff --git a/src/Angular.js b/src/Angular.js index 9b651fce4a4f..256a119c1308 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 */