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

Nested transclude issue #7387

Closed

Conversation

petebacondarwin
Copy link
Member

Solves the problem of transclude directives that contain transclude directives in their template.

Fixes #7240
Fixes #4969

@mary-poppins
Copy link

Thanks for the PR! Please check the items below to help us merge this faster. See the contributing docs for more information.

  • Uses the issue template (#7387)

If you need to make changes to your pull request, you can update the commit with git commit --amend.
Then, update the pull request with git push -f.

Thanks again for your help!

@petebacondarwin petebacondarwin added this to the 1.3.0-beta.9 milestone May 12, 2014
@IgorMinar IgorMinar modified the milestones: 1.3.0, 1.3.0-beta.9 May 12, 2014
@petebacondarwin petebacondarwin modified the milestones: 1.3.0-beta.9, 1.3.0 May 12, 2014
@petebacondarwin
Copy link
Member Author

I have added more tests when we have async templates and tidied up @vojtajina's fix.

expect(element.text().trim()).toEqual('transcluded content');
}));

it('should allow nested transclude directives with sync templates', inject(function($compile, $rootScope) {
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't we also create the same set of tests for async directives?

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree, they are two separate code paths and the other needs tests as well

Copy link
Member Author

Choose a reason for hiding this comment

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

Hold on! That is exactly what these tests do they were just badly named :-)

If you have two directives that both expect to receive transcluded content
the outer directive works but the inner directive never receives a
transclusion function. This only failed if the first transclude directive
was not the first directive found in compilation.

Fixes angular#7240
Closes angular#7387
vojtajina added a commit that referenced this pull request May 16, 2014
If you have two directives that both expect to receive transcluded content
the outer directive works but the inner directive never receives a
transclusion function. This only failed if the first transclude directive
was not the first directive found in compilation.

Fixes #7240
Closes #7387
IgorMinar pushed a commit to IgorMinar/angular.js that referenced this pull request May 16, 2014
If you have two directives that both expect to receive transcluded content
the outer directive works but the inner directive never receives a
transclusion function. This only failed if the first transclude directive
was not the first directive found in compilation.

Fixes angular#7240
Closes angular#7387
IgorMinar pushed a commit to IgorMinar/angular.js that referenced this pull request May 16, 2014
If you have two directives that both expect to receive transcluded content
the outer directive works but the inner directive never receives a
transclusion function. This only failed if the first transclude directive
was not the first directive found in compilation.

Fixes angular#7240
Closes angular#7387
vojtajina added a commit that referenced this pull request May 16, 2014
If you have two directives that both expect to receive transcluded content
the outer directive works but the inner directive never receives a
transclusion function. This only failed if the first transclude directive
was not the first directive found in compilation.

Fixes #7240
Closes #7387
@vojtajina vojtajina closed this in 4f03dc5 May 16, 2014
@@ -1346,7 +1349,9 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
}

nodeLinkFn.scope = newScopeDirective && newScopeDirective.scope === true;
nodeLinkFn.transclude = hasTranscludeDirective && childTranscludeFn;
Copy link
Contributor

Choose a reason for hiding this comment

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

@petebacondarwin shouldn't this depend on whether there is a template directive or not?
If there is a template directive, then we don't pass the transclusion, right?

At least that was what we came up with, I think...
vojtajina@e10bd88#diff-a732922b631efed1b9f33a24082ae0dbR1335

Copy link
Member Author

Choose a reason for hiding this comment

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

I moved this check further up the diff

Copy link
Member Author

Choose a reason for hiding this comment

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

@vojtajina - sorry about the short answer I was on my phone.

I looked through the logic and I am pretty sure that the logic here works out the same as our original diff.

Copy link
Member Author

Choose a reason for hiding this comment

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

      if (hasTranscludeDirective) {
        nodeLinkFn.transcludeOnThisElement = true;
      } else if (!templateDirective) {
        nodeLinkFn.transcludeOnThisElement = false;
      }

is equivalent to

nodeLinkFn.transcludeOnThisElement = hasTranscludeElement

since the default of this property is undefined (i.e. falsy)

Copy link
Contributor

Choose a reason for hiding this comment

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

The original code does not set nodeLinkFn.transclude if !hasTransclude && templateDirective.

Copy link
Contributor

Choose a reason for hiding this comment

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

@petebacondarwin Oh, thanks. Now I understand that the code does the same thing. You are right.

I'm still however not sure if that's correct, as template SHOULD be deciding factor, no?

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean, I understand that the code change you did, does not change any behavior, but I'm still questioning whether it is the correct behavior.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes I am willing to agree

Copy link
Contributor

Choose a reason for hiding this comment

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

This is what I was talking about. I think this failing test shows the problem:
vojtajina@4d152c8

Copy link
Contributor

Choose a reason for hiding this comment

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

We can fix that in a separate PR though.

@petebacondarwin
Copy link
Member Author

Hmm possibly...
On 19 May 2014 18:25, "Vojta Jina" notifications@github.com wrote:

@petebacondarwin https://github.com/petebacondarwin Oh, thanks. How I
understand that the code does the same thing.

I'm still however not sure if it's correct, as template SHOULD be deciding
factor, no?


Reply to this email directly or view it on GitHubhttps://github.com//pull/7387#issuecomment-43532268
.

petebacondarwin pushed a commit to petebacondarwin/angular.js that referenced this pull request May 21, 2014
If you have two directives that both expect to receive transcluded content
the outer directive works but the inner directive never receives a
transclusion function. This only failed if the first transclude directive
was not the first directive found in compilation.

Fixes angular#7240
Closes angular#7387
petebacondarwin added a commit to petebacondarwin/angular.js that referenced this pull request May 22, 2014
If you have two directives that both expect to receive transcluded content
the outer directive works but the inner directive never receives a
transclusion function. This only failed if the first transclude directive
was not the first directive found in compilation.

Handles the regression identified in e994259

Fixes angular#7240
Closes angular#7387
petebacondarwin added a commit to petebacondarwin/angular.js that referenced this pull request May 22, 2014
If you have two directives that both expect to receive transcluded content
the outer directive works but the inner directive never receives a
transclusion function. This only failed if the first transclude directive
was not the first directive found in compilation.

Handles the regression identified in e994259

Fixes angular#7240
Closes angular#7387
petebacondarwin added a commit that referenced this pull request May 23, 2014
If you have two directives that both expect to receive transcluded content
the outer directive works but the inner directive never receives a
transclusion function. This only failed if the first transclude directive
was not the first directive found in compilation.

Handles the regression identified in e994259

Fixes #7240
Closes #7387
RichardLitt pushed a commit to RichardLitt/angular.js that referenced this pull request May 24, 2014
If you have two directives that both expect to receive transcluded content
the outer directive works but the inner directive never receives a
transclusion function. This only failed if the first transclude directive
was not the first directive found in compilation.

Fixes angular#7240
Closes angular#7387
vojtajina pushed a commit to vojtajina/angular.js that referenced this pull request May 28, 2014
If you have two directives that both expect to receive transcluded content
the outer directive works but the inner directive never receives a
transclusion function. This only failed if the first transclude directive
was not the first directive found in compilation.

Handles the regression identified in e994259

Fixes angular#7240
Closes angular#7387
vojtajina pushed a commit to vojtajina/angular.js that referenced this pull request May 28, 2014
If you have two directives that both expect to receive transcluded content
the outer directive works but the inner directive never receives a
transclusion function. This only failed if the first transclude directive
was not the first directive found in compilation.

Handles the regression identified in e994259

Fixes angular#7240
Closes angular#7387
vojtajina pushed a commit to vojtajina/angular.js that referenced this pull request May 29, 2014
If you have two directives that both expect to receive transcluded content
the outer directive works but the inner directive never receives a
transclusion function. This only failed if the first transclude directive
was not the first directive found in compilation.

Handles the regression identified in e994259

Fixes angular#7240
Closes angular#7387
vojtajina pushed a commit to vojtajina/angular.js that referenced this pull request May 29, 2014
If you have two directives that both expect to receive transcluded content
the outer directive works but the inner directive never receives a
transclusion function. This only failed if the first transclude directive
was not the first directive found in compilation.

Handles the regression identified in e994259

Fixes angular#7240
Closes angular#7387
caitp pushed a commit to caitp/angular.js that referenced this pull request Jun 13, 2014
If you have two directives that both expect to receive transcluded content
the outer directive works but the inner directive never receives a
transclusion function. This only failed if the first transclude directive
was not the first directive found in compilation.

Handles the regression identified in e994259

Fixes angular#7240
Closes angular#7387
petebacondarwin added a commit that referenced this pull request Jun 13, 2014
If you have two directives that both expect to receive transcluded content
the outer directive works but the inner directive never receives a
transclusion function. This only failed if the first transclude directive
was not the first directive found in compilation.

Handles the regression identified in e994259

Fixes #7240
Closes #7387
@timkendrick
Copy link
Contributor

@petebacondarwin: I'm still experiencing issues with nested transcludes in version 1.3.0-rc.0.

JSFiddle example here – in the second test, the nested transclude is ignored.

It seems to lose the transcluded content when the ng-transclude is applied to the same element as the nested directive within the outer directive's template.

It works if the ng-transclude is applied to a wrapper element inside the nested directive (but then you're left with an irritating wrapper element).

Is this the same issue?

@IgorMinar
Copy link
Contributor

@timkendrick, it's a similar but different issue, so I reposted your comment as #8914

@vojtajina
Copy link
Contributor

Yes, @timkendrick 's fiddle shows a valid issue.

Just not sure how high priority this should be as there is a simple work-around.
It's not a regression, it is a more specific corner case that we didn't think of.

@timkendrick
Copy link
Contributor

Thanks for the quick response guys!

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