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

fix(angular): Allow widgets to be styled in IE8 and below #616

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions regression/issue-584.html
Original file line number Diff line number Diff line change
@@ -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>
17 changes: 16 additions & 1 deletion src/Angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,21 @@ 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} element Name of the widget.
* @returns {string} Lowercased string.
*/
function shivForIE(elementName) {
elementName = lowercase(elementName);
if (msie < 9 && element.indexOf('@') == -1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be elementName.charAt(0) !== '@'

I'll fix that during squash

document.createElement(elementName);
return elementName;
}

var _undefined = undefined,
_null = null,
Expand Down Expand Up @@ -91,7 +106,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 */
Expand Down