X Tutup
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions modules/angular2/src/core/compiler/template_parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -655,12 +655,12 @@ class Component {

findNgContentIndex(selector: CssSelector): number {
var ngContentIndices = [];
if (isPresent(this.wildcardNgContentIndex)) {
ngContentIndices.push(this.wildcardNgContentIndex);
}
this.ngContentIndexMatcher.match(
selector, (selector, ngContentIndex) => { ngContentIndices.push(ngContentIndex); });
ListWrapper.sort(ngContentIndices);
if (isPresent(this.wildcardNgContentIndex)) {
ngContentIndices.push(this.wildcardNgContentIndex);
}
return ngContentIndices.length > 0 ? ngContentIndices[0] : null;
}
}
Expand Down
6 changes: 6 additions & 0 deletions modules/angular2/test/core/compiler/template_parser_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,12 @@ There is no directive with "exportAs" set to "dirA" at TestComp > div:nth-child(
.toEqual([['div', null], ['#text(hello)', 2], ['b', 1], ['a', 0]]);
});

it('should project into wildcard ng-content last', () => {
expect(humanizeContentProjection(
parse('<div>hello<a></a></div>', [createComp('div', ['*', 'a'])])))
.toEqual([['div', null], ['#text(hello)', 0], ['a', 1]]);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is outside the scope of this PR, but we should do something about our test code readability. This is hardly readable.

});

it('should only project direct child nodes', () => {
expect(humanizeContentProjection(
parse('<div><span><a></a></span><a></a></div>', [createComp('div', ['a'])])))
Expand Down
X Tutup