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

Commit 5a5808a

Browse files
fix($compile): include non-elements in default transclusion slot
See a4ada8b#commitcomment-14738387
1 parent b4fc2f7 commit 5a5808a

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

src/ng/compile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1893,7 +1893,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
18931893
});
18941894

18951895
// Add the matching elements into their slot
1896-
forEach($compileNode.children(), function(node) {
1896+
forEach($compileNode.contents(), function(node) {
18971897
var slotName = slotNames[directiveNormalize(nodeName_(node))];
18981898
if (slotName) {
18991899
filledSlots[slotName] = true;

test/ng/compileSpec.js

+30
Original file line numberDiff line numberDiff line change
@@ -7714,6 +7714,36 @@ describe('$compile', function() {
77147714
});
77157715
});
77167716

7717+
7718+
it('should include non-element nodes in the default transclusion', function() {
7719+
module(function() {
7720+
directive('minionComponent', function() {
7721+
return {
7722+
restrict: 'E',
7723+
scope: {},
7724+
transclude: {
7725+
boss: 'bossSlot'
7726+
},
7727+
template:
7728+
'<div class="other" ng-transclude></div>'
7729+
};
7730+
});
7731+
});
7732+
inject(function($rootScope, $compile) {
7733+
element = $compile(
7734+
'<minion-component>' +
7735+
'text1' +
7736+
'<span>stuart</span>' +
7737+
'<span>bob</span>' +
7738+
'<boss>gru</boss>' +
7739+
'text2' +
7740+
'<span>kevin</span>' +
7741+
'</minion-component>')($rootScope);
7742+
$rootScope.$apply();
7743+
expect(element.text()).toEqual('text1stuartbobtext2kevin');
7744+
});
7745+
});
7746+
77177747
it('should transclude elements to an `ng-transclude` with a matching transclusion slot name', function() {
77187748
module(function() {
77197749
directive('minionComponent', function() {

0 commit comments

Comments
 (0)