aboutsummaryrefslogtreecommitdiffstats
path: root/src/ng/directive/booleanAttrs.js
diff options
context:
space:
mode:
authorIgor Minar2012-04-11 23:46:23 -0700
committerIgor Minar2012-04-12 02:36:03 -0700
commit6d7e7fdea6c3d6551ff40c150aa42e1375d2cb5f (patch)
tree47cc1d0f24f424df8f964595ee98a4c6b30bb981 /src/ng/directive/booleanAttrs.js
parentdf72852f3496d7640bb4f70837338e464b7ed69f (diff)
downloadangular.js-6d7e7fdea6c3d6551ff40c150aa42e1375d2cb5f.tar.bz2
fix($location): properly rewrite urls in html5 mode with base url set
previously we were doing all kinds of checks to see if we should rewrite the url or not and we were missing many scenarios. not any more. with this change, we rewrite the url unless: - the href is not set - link has target attribute - the absolute url of the link doesn't match the absolute prefix for all urls in our app This also means that ng-ext-link attribute which we previously used to distinguish external links from app links is not necessary any more. apps can just set target=_self to prevent rewriting. BREAKING CHANGE: ng-ext-link directive was removed because it's unnecessary apps that relied on ng-ext-link should simply replace it with target=_self
Diffstat (limited to 'src/ng/directive/booleanAttrs.js')
-rw-r--r--src/ng/directive/booleanAttrs.js14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/ng/directive/booleanAttrs.js b/src/ng/directive/booleanAttrs.js
index e25b259c..5da98ef4 100644
--- a/src/ng/directive/booleanAttrs.js
+++ b/src/ng/directive/booleanAttrs.js
@@ -6,7 +6,7 @@
* @restrict A
*
* @description
- * Using <angular/> markup like {{hash}} in an href attribute makes
+ * Using Angular markup like {{hash}} in an href attribute makes
* the page open to a wrong URL, if the user clicks that link before
* angular has a chance to replace the {{hash}} with actual URL, the
* link will be broken and will most likely return a 404 error.
@@ -32,10 +32,10 @@
<input ng-model="value" /><br />
<a id="link-1" href ng-click="value = 1">link 1</a> (link, don't reload)<br />
<a id="link-2" href="" ng-click="value = 2">link 2</a> (link, don't reload)<br />
- <a id="link-3" ng-href="/{{'123'}}" ng-ext-link>link 3</a> (link, reload!)<br />
+ <a id="link-3" ng-href="/{{'123'}}">link 3</a> (link, reload!)<br />
<a id="link-4" href="" name="xx" ng-click="value = 4">anchor</a> (link, don't reload)<br />
<a id="link-5" name="xxx" ng-click="value = 5">anchor</a> (no link)<br />
- <a id="link-6" ng-href="/{{value}}" ng-ext-link>link</a> (link, change hash)
+ <a id="link-6" ng-href="{{value}}">link</a> (link, change location)
</doc:source>
<doc:scenario>
it('should execute ng-click but not reload when href without value', function() {
@@ -60,21 +60,21 @@
it('should execute ng-click but not reload when href empty string and name specified', function() {
element('#link-4').click();
expect(input('value').val()).toEqual('4');
- expect(element('#link-4').attr('href')).toBe("");
+ expect(element('#link-4').attr('href')).toBe('');
});
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('');
});
it('should only change url when only ng-href', function() {
input('value').enter('6');
- expect(element('#link-6').attr('href')).toBe("/6");
+ expect(element('#link-6').attr('href')).toBe('6');
element('#link-6').click();
- expect(browser().window().path()).toEqual('/6');
+ expect(browser().location().url()).toEqual('/6');
});
</doc:scenario>
</doc:example>