This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.5k
ngHref prematurely adds href attribute when string is included as part of the expression #6984
Milestone
Comments
briangershon
changed the title
ngHref prematurely generate href when string is included as part of the expression
ngHref prematurely adds href attribute when string is included as part of the expression
Apr 3, 2014
This is a known issue; I actually just wrote about it here: http://briantford.com/blog/angular-hacking-core.html |
Thanks @btford for triaging, I'll check out your blog article. |
There's a significant pending change to |
@nicoabie thanks, but it's better to leave feedback on my post on the repo for my blog rather than here. This thread is for discussing a solution. |
btford
added a commit
to btford/angular.js
that referenced
this issue
Apr 28, 2014
… defined BREAKING CHANGE If `bar` is `undefined`, before `<img src="foo/{{bar}}.jpg">` yields `<img src="foo/.jpg">`. With this change, the binding will not set `src`. If you want the old behavior, you can do this: `<img src="foo/{{bar || ''}}.jpg">`. The same applies for `srcset` and `href`. Closes angular#6984
btford
added a commit
to btford/angular.js
that referenced
this issue
Apr 28, 2014
… defined BREAKING CHANGE If `bar` is `undefined`, before `<img src="foo/{{bar}}.jpg">` yields `<img src="foo/.jpg">`. With this change, the binding will not set `src`. If you want the old behavior, you can do this: `<img src="foo/{{bar || ''}}.jpg">`. The same applies for `srcset` and `href`. Closes angular#6984
btford
added a commit
to btford/angular.js
that referenced
this issue
Apr 28, 2014
… defined BREAKING CHANGE If `bar` is `undefined`, before `<img src="foo/{{bar}}.jpg">` yields `<img src="foo/.jpg">`. With this change, the binding will not set `src`. If you want the old behavior, you can do this: `<img src="foo/{{bar || ''}}.jpg">`. The same applies for `srcset` and `href`. Closes angular#6984
btford
added a commit
to btford/angular.js
that referenced
this issue
Apr 29, 2014
… defined BREAKING CHANGE If `bar` is `undefined`, before `<img src="foo/{{bar}}.jpg">` yields `<img src="foo/.jpg">`. With this change, the binding will not set `src`. If you want the old behavior, you can do this: `<img src="foo/{{bar || ''}}.jpg">`. The same applies for `srcset` and `href`. Closes angular#6984
btford
added a commit
to btford/angular.js
that referenced
this issue
Apr 30, 2014
… defined BREAKING CHANGE If `bar` is `undefined`, before `<img src="foo/{{bar}}.jpg">` yields `<img src="foo/.jpg">`. With this change, the binding will not set `src`. If you want the old behavior, you can do this: `<img src="foo/{{bar || ''}}.jpg">`. The same applies for `srcset` and `href`. Closes angular#6984
btford
added a commit
to btford/angular.js
that referenced
this issue
Apr 30, 2014
… defined BREAKING CHANGE If `bar` is `undefined`, before `<img src="foo/{{bar}}.jpg">` yields `<img src="foo/.jpg">`. With this change, the binding will not set `src`. If you want the old behavior, you can do this: `<img src="foo/{{bar || ''}}.jpg">`. The same applies for `srcset` and `href`. Closes angular#6984
btford
added a commit
to btford/angular.js
that referenced
this issue
Apr 30, 2014
… defined BREAKING CHANGE If `bar` is `undefined`, before `<img src="foo/{{bar}}.jpg">` yields `<img src="foo/.jpg">`. With this change, the binding will not set `src`. If you want the old behavior, you can do this: `<img src="foo/{{bar || ''}}.jpg">`. The same applies for `srcset` and `href`. Closes angular#6984
btford
added a commit
to btford/angular.js
that referenced
this issue
Apr 30, 2014
… defined BREAKING CHANGE If `bar` is `undefined`, before `<img src="foo/{{bar}}.jpg">` yields `<img src="foo/.jpg">`. With this change, the binding will not set `src`. If you want the old behavior, you can do this: `<img src="foo/{{bar || ''}}.jpg">`. The same applies for `srcset` and `href`. Closes angular#6984
btford
added a commit
to btford/angular.js
that referenced
this issue
May 1, 2014
… defined BREAKING CHANGE If `bar` is `undefined`, before `<img src="foo/{{bar}}.jpg">` yields `<img src="foo/.jpg">`. With this change, the binding will not set `src`. If you want the old behavior, you can do this: `<img src="foo/{{bar || ''}}.jpg">`. The same applies for `srcset` and `href`. Closes angular#6984
btford
added a commit
to btford/angular.js
that referenced
this issue
May 2, 2014
BREAKING CHANGE If `bar` is `undefined`, before `<img src="foo/{{bar}}.jpg">` yields `<img src="foo/.jpg">`. With this change, the binding will not set `src`. If you want the old behavior, you can do this: `<img src="foo/{{bar || ''}}.jpg">`. The same applies for `srcset` as well. Closes angular#6984
btford
added a commit
to btford/angular.js
that referenced
this issue
May 2, 2014
BREAKING CHANGE If `bar` is `undefined`, before `<img src="foo/{{bar}}.jpg">` yields `<img src="foo/.jpg">`. With this change, the binding will not set `src`. If you want the old behavior, you can do this: `<img src="foo/{{bar || ''}}.jpg">`. The same applies for `srcset` as well. Closes angular#6984
btford
added a commit
to btford/angular.js
that referenced
this issue
May 2, 2014
BREAKING CHANGE If `bar` is `undefined`, before `<img src="foo/{{bar}}.jpg">` yields `<img src="foo/.jpg">`. With this change, the binding will not set `src`. If you want the old behavior, you can do this: `<img src="foo/{{bar || ''}}.jpg">`. The same applies for `srcset` as well. Closes angular#6984
btford
added a commit
to btford/angular.js
that referenced
this issue
May 2, 2014
BREAKING CHANGE If `bar` is `undefined`, before `<img src="foo/{{bar}}.jpg">` yields `<img src="foo/.jpg">`. With this change, the binding will not set `src`. If you want the old behavior, you can do this: `<img src="foo/{{bar || ''}}.jpg">`. The same applies for `srcset` as well. Closes angular#6984
btford
added a commit
to btford/angular.js
that referenced
this issue
May 2, 2014
BREAKING CHANGE If `bar` is `undefined`, before `<img src="foo/{{bar}}.jpg">` yields `<img src="foo/.jpg">`. With this change, the binding will not set `src`. If you want the old behavior, you can do this: `<img src="foo/{{bar || ''}}.jpg">`. The same applies for `srcset` as well. Closes angular#6984
btford
added a commit
to btford/angular.js
that referenced
this issue
May 2, 2014
BREAKING CHANGE If `bar` is `undefined`, before `<img src="foo/{{bar}}.jpg">` yields `<img src="foo/.jpg">`. With this change, the binding will not set `src`. If you want the old behavior, you can do this: `<img src="foo/{{bar || ''}}.jpg">`. The same applies for `srcset` as well. Closes angular#6984
Thanks @btford for your work on this! |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The ngHref doc page gives an example of the correct way of using ngHref to avoid broken URLs until {{hash}} is evaluated.
I've created a plunker that demonstrates that this generates the href attribute right away, prior to the {{hash}} evaluating, so the full url is not yet valid.
My understanding is that we should not see either link until {{hash}} is filled in (via the input box), but in the first link example in this plunker we do see an active link:
http://plnkr.co/EOWiCm
I traced through and it seems that the $observe() call is placed on the whole ngHref value and not just the {{hash}}.
Seeing this happen in Angular 1.2.9 through 1.3.0-beta.4 (which the Plunker example is using). Reproduced in Chrome and Safari.
I wasn't able to find a similar bug report.
Potential fix:
The fix might be parsing the ngHref attribute and just observing when the {{hash}} changes and not the string around it. Here was the snippet that was adding the observers in booleanAttrs.js.
The text was updated successfully, but these errors were encountered: