aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorIgor Minar2013-02-14 15:13:50 -0800
committerIgor Minar2013-02-14 16:42:58 -0800
commit37e8b12265291918396bfee65d444a8f63697b73 (patch)
treec4eed144b5c9931c9ccb750b32213c5b55962c5e /src
parent1ace5eb39632ae189fdabee176c6e918960d0578 (diff)
downloadangular.js-37e8b12265291918396bfee65d444a8f63697b73.tar.bz2
fix(a): workaround IE bug affecting mailto urls
Apparently there is a really weird bug in IE6-8 that causes anchor textContent to be reset with href content when both contain @ symbol. Inserting a bogus comment node into all anchor elements in IE works around this browser bug. I'm fixing the issue via directive because that way we'll fix it for jQuery as well. I fixed an e2e test too because it was incorrect. Closes #1949
Diffstat (limited to 'src')
-rw-r--r--src/ng/directive/a.js18
-rw-r--r--src/ng/directive/booleanAttrs.js2
2 files changed, 15 insertions, 5 deletions
diff --git a/src/ng/directive/a.js b/src/ng/directive/a.js
index 9b6c67c9..7ee8f572 100644
--- a/src/ng/directive/a.js
+++ b/src/ng/directive/a.js
@@ -16,10 +16,20 @@
var htmlAnchorDirective = valueFn({
restrict: 'E',
compile: function(element, attr) {
- // turn <a href ng-click="..">link</a> into a link in IE
- // but only if it doesn't have name attribute, in which case it's an anchor
- if (!attr.href) {
- attr.$set('href', '');
+
+ if (msie <= 8) {
+
+ // turn <a href ng-click="..">link</a> into a stylable link in IE
+ // but only if it doesn't have name attribute, in which case it's an anchor
+ if (!attr.href && !attr.name) {
+ attr.$set('href', '');
+ }
+
+ // add a comment node to anchors to workaround IE bug that causes element content to be reset
+ // to new attribute content if attribute is updated with value containing @ and element also
+ // contains value with @
+ // see issue #1949
+ element.append(document.createComment('IE fix'));
}
return function(scope, element) {
diff --git a/src/ng/directive/booleanAttrs.js b/src/ng/directive/booleanAttrs.js
index 2d1278cd..739c539a 100644
--- a/src/ng/directive/booleanAttrs.js
+++ b/src/ng/directive/booleanAttrs.js
@@ -66,7 +66,7 @@
it('should execute ng-click but not reload when no href but name specified', function() {
element('#link-5').click();
expect(input('value').val()).toEqual('5');
- expect(element('#link-5').attr('href')).toBe('');
+ expect(element('#link-5').attr('href')).toBe(undefined);
});
it('should only change url when only ng-href', function() {