Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 163c799

Browse files
dmanekIgorMinar
authored andcommitted
fix(angular.widget): Allow widgets to be styled in IE8 and below
Closes #584
1 parent 7da70af commit 163c799

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

regression/issue-584.html

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!DOCTYPE html>
2+
<html xmlns:ng="http://angularjs.org" xmlns:my="http://mynamespace.org">
3+
<head>
4+
<style>
5+
my\:time {color:#00f;display:block;border:1px solid #ccc;background-color:#ddd;}
6+
</style>
7+
<script src="../build/angular.js" ng:autobind></script>
8+
<script>
9+
angular.widget('my:time', function(compileElement){
10+
compileElement.css('display', 'block');
11+
return function(linkElement) {
12+
function update() {
13+
linkElement.text('Current time is: ' + new Date());
14+
setTimeout(update, 1000);
15+
}
16+
update();
17+
};
18+
});
19+
</script>
20+
</head>
21+
<body>
22+
<my:time></my:time>
23+
</body>
24+
</html>

src/Angular.js

+17-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,22 @@ if ('i' !== 'I'.toLowerCase()) {
5151

5252
function fromCharCode(code) { return String.fromCharCode(code); }
5353

54+
/**
55+
* Creates the element for IE8 and below to allow styling of widgets
56+
* (http://ejohn.org/blog/html5-shiv/). This hack works only if angular is
57+
* included synchronously at the top of the document before IE sees any
58+
* unknown elements. See regression/issue-584.html.
59+
*
60+
* @param {string} elementName Name of the widget.
61+
* @returns {string} Lowercased string.
62+
*/
63+
function shivForIE(elementName) {
64+
elementName = lowercase(elementName);
65+
if (msie < 9 && elementName.charAt(0) != '@') { // ignore attr-widgets
66+
document.createElement(elementName);
67+
}
68+
return elementName;
69+
}
5470

5571
var _undefined = undefined,
5672
_null = null,
@@ -91,7 +107,7 @@ var _undefined = undefined,
91107
/** @name angular.directive */
92108
angularDirective = extensionMap(angular, 'directive'),
93109
/** @name angular.widget */
94-
angularWidget = extensionMap(angular, 'widget', lowercase),
110+
angularWidget = extensionMap(angular, 'widget', shivForIE),
95111
/** @name angular.filter */
96112
angularFilter = extensionMap(angular, 'filter'),
97113
/** @name angular.service */

0 commit comments

Comments
 (0)