Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix(ngTransclude): 'cos things are never simple #14787

Closed
wants to merge 1 commit into from

Conversation

petebacondarwin
Copy link
Contributor

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

fix

What is the current behavior? (You can also link to an open issue here)

broken

What is the new behavior (if this is a feature change)?

fixed (see below)

Does this PR introduce a breaking change?

nope

Please check if the PR fulfills these requirements

Other information:

transcludedScope.$destroy();
function ngTranscludeCloneAttachFn(clone, transcludedScope) {
if (clone.length) {
$element.append(clone);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also release any fallback contents for GC (e.g. fallbackContents = null) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds reasonable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this is more complicated. We need to compile this content into a linking function, which we will use to link and clone the fallback content, in the case that this appears inside an ng-repeat.

@petebacondarwin
Copy link
Contributor Author

@dcherman and @gkalpak PTAL

compile: function ngTranscludeCompile(tElement) {

// Remove and cache any original content to act as a fallback
var fallbackLinkFn = $compile(tElement.contents());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How common do you feel it is to use fallback content and have the user not provide their own? Wondering if it's worth calling $compile the first time the fallback content is needed rather than at compile time, but I have no idea how common this usage is to determine whether or not that'd be worth it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is faster than the situation we had before before your PR, since then we were compiling AND linking the fallback content, even if it was never used.
We could optimize to lazy compile the content, but I would like to see some numbers that show it makes any real difference before doing so.

@gkalpak
Copy link
Member

gkalpak commented Jun 17, 2016

LGTM

@petebacondarwin
Copy link
Contributor Author

Thanks @gkalpak - merging

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants