-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Nested transclude issue 2 #8914
Comments
@vojtajina could you take a look at this one please? |
Reopening as the commit was reverted. |
See 06fa286 |
@petebacondarwin could you have another look on this? |
👍 ran into this today |
I think there's a conceptual mismatch between how the fiddle assumes transclusion to work and how it actually works. In short, transclusion determines the content that will be transcluded during compilation, whereas the transclusion itself is actually done during linking. Whether it’s done with So with these directives: app.directive('inner', function() {
return {
transclude: true,
template: '<u ng-transclude></u>'
};
});
app.directive('outer', function() {
return {
transclude: true,
template: '<a href="#"><inner ng-transclude></inner></a>'
};
});
app.directive('workaround', function() {
return {
transclude: true,
template: '<a href="#"><inner><foo ng-transclude></foo></inner></a>'
};
}); The fiddle’s assumption seems to be that this would happen with the when applied to
However, what actually happens is: At compilation time:
At linking time
The For the “workaround” case in the fiddle the mental model holds, because There’s probably a way to fix this. To me it seems like it would mean a way for $compile to know not only where |
@teropa thanks for the break down of why this is happening. However, while the jsbin's mental model might not match the current implementation, it does match the expectation of what the correct behavior would be -- this is kind of the definition of a "bug". If you have a directive like outer with this template: <a href="#"><inner ng-transclude></inner></a>
This forces |
@fenduru Agreed, this is a leaky abstraction at the moment. |
@teropa - do you have any ideas of how to fix this? I have no capacity and this is a fairly uncommon corner case. Assigning to the Ice Box for now. |
(reposting from (comment)[https://github.com//pull/7387#issuecomment-54363122])
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).
The text was updated successfully, but these errors were encountered: