-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix ($compile): keeps prototype properties for template URL directives #10926
fix ($compile): keeps prototype properties for template URL directives #10926
Conversation
i could see this being useful for typescript/coffeescript users, and it is a pretty small fix. lgtm, but wait for pete or someone else to signoff on it |
Marking this for beta 3, but this should probably wait for beta 4. /cc @petebacondarwin |
LGTM - let's get this in next week. Thanks for taking a look @caitp and pinging me. |
looks good, the only thing I would like to see is the same test using |
Quick work @hannahhoward - nicely done and nice PR. Thanks |
added second test per request. and removed the accidental leftover console.log. I'm not sure why the build is failing on Firefox 31.0 on Linux |
@@ -2156,7 +2156,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) { | |||
beforeTemplateCompileNode = $compileNode[0], | |||
origAsyncDirective = directives.shift(), | |||
// The fact that we have to copy and patch the directive seems wrong! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment doesn't reflect the code below it anymore.
removed the outdated comment |
Looks very good. Just one more thing @hannahhoward can you please squash everything into one commit? Thanks! |
Actually @hannahhoward don't worry, we can squash when we merge. |
Previously, if a directive definition object was defined with methods like `compile` provided on the prototype rather than the instance, the Angular compiler failed to use these methods when the directive had a `templateURL`. This change ensures that these prototypical methods are not lost. This enables developers to define their directives using "classes" such as in CoffeeScript or ES6. Closes #10926
currently, if a directive definition objects has prototype properties, such as a compile function, those are lost when compiled if the directive has a templateUrl function. Steps to reproduce:
The DDO's compile function will never be called. On the other hand the same version with a plain template works:
The DDO's compile function will be called.
This makes a difference for an increasing number of people particularly who are experimenting with ES6 classes in Angular 1.x.