-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Directive require doesn't throw without link... #3941
Comments
This seems like a reasonable request. We should probably create a noop link function if one is not provided. @IgorMinar & @mhevery - is there any reason why we shouldn't do this? |
@petebacondarwin - creating a default noop link function when none has been provided seems to break a couple of compile test cases where transluction, templateUrl and replacement are in the mix so it can't be applied in every situation but does work if checking for the specific scenario outlined above. |
@colincasey @petebacondarwin Why not just dirty check the link member and, if it doesn't exist, simply ignore the function call? |
Also, I seem to be having an issue reproducing any sort of issue. I don't really understand the need for compile to throw an error if link does not exist? Seems like adding rigidity without a particular use case, unless you provide one @iammerrick ? |
Absolutely. What I showed above is a perfectly sound usecase, a directive that composes other directives. |
+1 to this. This is important to highlight requirements of a directive during its usage. Right now, I use |
I don't see why we should throw here --- there's no reason to need a link function for a directive if you're just using it to add/replace a template to your element. Not calling link functions that we don't need to is a win, imo --- if someone can convince me otherwise, I'm happy to be convinced |
This won't throw unless a link function is added to the directive...
http://jsbin.com/ikIpuri/1/edit
The text was updated successfully, but these errors were encountered: