mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-16 23:30:23 +00:00
fix(angular.widget): Allow widgets to be styled in IE8 and below
Closes #584
This commit is contained in:
parent
7da70af1ae
commit
163c799eff
2 changed files with 41 additions and 1 deletions
24
regression/issue-584.html
Normal file
24
regression/issue-584.html
Normal file
|
|
@ -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>
|
||||
|
|
@ -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 */
|
||||
|
|
|
|||
Loading…
Reference in a new issue