-
Notifications
You must be signed in to change notification settings - Fork 27.4k
feat(ngTransclude & $compile): fix treatment of unfilled optional slots #13431
feat(ngTransclude & $compile): fix treatment of unfilled optional slots #13431
Conversation
@PascalPrecht - hey look at this! |
@petebacondarwin awesome! Does this also keep the original contents of the DOM where we transclude into? E.g.
|
Yep! That is the second commit in the PR. |
Argh. I just've just read the commit messages instead of reading the code haha. Awesome! Thanks for the work! |
if (slotTranscludeFn) { | ||
return slotTranscludeFn(scope, cloneAttachFn, transcludeControllers, futureParentElement, scopeToChild); | ||
} | ||
if (isUndefined(slotTranscludeFn)) { |
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.
how about just else
?
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.
We have to differentiate between null
and undefined
. I will add a comment to clarify.
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.
Okay, I just noticed there's no difference in test behavior.
Isn't the commit message a bit contradictory? It's called a feature but And a question, is it possible to keep the content with the default behavior (no slots, transclude is true or content)? Since people have requested something similar for the default ngTransclude: #11839 |
We could make |
Regarding default content for the default transclusion, perhaps we could special case transclude: {
'required': 'requiredSlot',
'optional': '?optionalSlot',
'': '?' // this would make the default transclusion optional too...
} and if you wanted optional default transclusion only then you would put: transclude: { '': '?' } |
Then we should also document For default transchlusion. Okay, I forgot you can have default transclusion and slots. The proposed API for that looks a bit silly, but it's probably okay. But we can also decide on that after 1.5 |
Hmm it is a bit awkward to make the default transclusion optional. I think we should punt that feature to post-1.5.0 |
5a5808a
to
c063544
Compare
We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm. |
Looks like the last commit caused some doc e2e tests to fail. :o Other than that, feel free to merge. We can tweak it after the fact. |
5ec2fed
to
de2d5a5
Compare
de2d5a5
to
a38d298
Compare
…ional slot Previously the contents of the `ngTransclude` element would always be emptied, even if there was no transclusion to replace it. Now, optional slots that have not been filled with content will not cause the `ngTransclude` contents to be emptied. Closes angular#13426
a38d298
to
e94b37e
Compare
Closes #13426