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.
fix(ngTransclude): clear the translusion point before transcluding
when the transluded content is being teleported to the translusion point, we should ensure that the translusion point is empty before appending otherwise we end up with junk before the transcluded content
- Loading branch information
Showing
2 changed files
with
24 additions
and
3 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
eed299a
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.
Oh my god...this breaking change break all my directives that use ngTransclude in the template.
I don't get it, How could there be 'junk' in the translusion point if we don't put them in the template? Isn't that 'junk' element in the template mean to be there?
eed299a
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've a similar issue and looking for a work around.
@aptx4869, were you able to find any solution?
eed299a
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 haven't found a work-around either. I also can't figure out why there would be "junk" in the transclusion point. If my template is "<div ng-transclude>foo</div>", what I want is for the transcluded content to be appended, not replaced. I do not see a good reason for this change.
I'm going to try my hand at an "ng-transclude-append" directive which follows the old semantics.
eed299a
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.
Igor, I've submitted a bug along with plunker examples #5060
Can you take a look. Thanks
eed299a
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 kind of unfortunate. The old behavior seemed perfectly acceptable to me. As others have said already, it's hard to think of any situation where there would be leftover tags within the transclusion point.
There is a workaround, though, by manually transcluding the content:
But doing that in every directive that uses transclusion isn't practical. So, inspired by @frogomatic message, I've created a
ng-transclude-append
directive that does what the oldng-transclude
used to: https://gist.github.com/mbenford/7623472.I've also created a Plunker script that shows it working: http://plnkr.co/edit/EjO8SpUT91PuXP0RMuJx.
At the end of the day, it would be really nice if
ngTransclude
had an option to append the transcluded content without clearing the target element.eed299a
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.
The append behavior will not work when we change the implementation to use Shadow DOM. See my comment here: #5060 (comment)
eed299a
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.
Thanks for the clarification, Brian. It makes sense now why you guys have changed the directive's behavior. But I think that the commit message lacks that explanation, though. It would have probably prevented this discussion from happening. ;)
eed299a
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.
you spoke my mind @mbenford