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
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf($compile): Lazily compile the
transclude
function
For transcluded directives, the transclude function can be lazily compiled most of the time since the contents will not be needed until the `transclude` function was actually invoked. For example, the `transclude` function that is passed to `ng-if` or `ng-switch-when` does not need to be invoked until the condition that it's bound to has been matched. For complex trees or switch statements, this can represent significant performance gains since compilation of branches is deferred, and that compilation may never actually happen if it isn't needed. There are two instances where compilation will not be lazy; when we scan ahead in the array of directives to be processed and find at least two of the following: * A directive that is transcluded and does not allow multiple transclusion * A directive that has templateUrl and replace: true * A directive that has a template and replace: true In both of those cases, we will need to continue eager compilation in order to generate the multiple transclusion exception at the correct time.
- Loading branch information
Showing
2 changed files
with
263 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
652b83e
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 commit seems to break a transcluded directive on my own code.
652b83e
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.
@gunta can you please create a plunker that shows the error
652b83e
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.
Is it a potential benefit to be able to opt out of the eager load? For instance, if I knew that a directive was going to break because of it (looking at you ui-select), being able to say
eagerLoad: true
in the directive.This gives the flexibility to opt-out, but still has it on by default. It's fairly trivial given it just needs to pass
mightHaveMultipleTransclusionError || directive.eagerLoad
652b83e
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.
A subtle breaking change like this that isn't intended to be a breaking change might classify as a bug. Either that, or it should be properly identified as something that can cause bugs. Whether the core team thinks [that isn't how it should be used] does not impact how people are using it and expect it to work. Opting out gives a grace period before it is deprecated.
652b83e
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.
@sb8244 do you have another example that is not ui-select? If you have one, then it would be nice to get one. The reason I am asking for another example is that ui-select is broken as it made some assumptions that were false even before Angular released 1.0. Here http://plnkr.co/edit/sRIW4LJ2VpSBJZAnODvY?p=preview is the proof that ui-select breaks with Angular 1.4.
I find that statement very unfair:
Now, the Angular core team is doing many underlying changes trying to improve the experience for all Angular apps while keeping the API and behavior stable. When things break, effort is made to fix it. When some behavior is not properly documented, we do so. The issue you are raising does no fall into any of these categories as it was possible to trigger this behavior before Angular 1.5 and the behavior is documented.
652b83e
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.
Apologies for the strong statement. I've seen this particular one be closed on issues and swept off as a ui-select issue so that
resolution: not-core
happens. I actually don't think there is an open issue to discuss it at the moment.My goal was to provide an alternative (opt-out). It seems that isn't the direction to go unless other apps have a problem. Totally cool.
One thing I love about angular is the breaking change list, it makes it very easy to follow along and I get a checklist of things to go through when I upgrade. While this isn't a breaking change, I think it highlights the fact that the change ends up breaking things (that weren't directly supported). A potential breaking change for this might look like:
Thanks for 1.5.0, it looks like a great release. I don't want to turn a commit comment into a huge thing, so take it with a grain of salt.
~ Steve
652b83e
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.
I think the opt-out option would be good here. See the trivial case of animations fail here: #14074
652b83e
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 is also causing problems with my usage of ui-grid