Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Commit 3141d32

Browse files
committed
fix(transcluding_component_factory): fix content detach logic
detachContent was finding the wrong end comment node and failing on assetion (in checked mode).
1 parent b691fd9 commit 3141d32

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

lib/core_dom/transcluding_component_factory.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class ContentPort {
5252

5353
var next;
5454
for (next = _beginComment.nextNode;
55-
next.nodeType != dom.Node.COMMENT_NODE && next.text != endCommentText;
55+
next.nodeType != dom.Node.COMMENT_NODE || next.text != endCommentText;
5656
next = _beginComment.nextNode) {
5757
_childNodes.add(next);
5858
next.remove();

test/core_dom/compiler_spec.dart

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ forBothCompilers(fn) {
1919
});
2020
fn();
2121
});
22+
}
23+
24+
forAllCompilersAndComponentFactories(fn) {
25+
forBothCompilers(fn);
2226

2327
describe('transcluding components', () {
2428
beforeEachModule((Module m) {
@@ -33,6 +37,29 @@ forBothCompilers(fn) {
3337

3438
void main() {
3539
forBothCompilers(() =>
40+
describe('TranscludingComponentFactory', () {
41+
TestBed _;
42+
43+
beforeEachModule((Module m) {
44+
return m
45+
..bind(ComponentFactory, toImplementation: TranscludingComponentFactory)
46+
..bind(SimpleComponent);
47+
});
48+
49+
beforeEach(inject((TestBed tb) => _ = tb));
50+
51+
it('should correctly detach transcluded content when scope destroyed', async(() {
52+
var scope = _.rootScope.createChild({});
53+
var element = _.compile(r'<div><simple><span ng-if="true == true">trans</span></simple></div>', scope: scope);
54+
microLeap();
55+
_.rootScope.apply();
56+
expect(element).toHaveText('INNER(trans)');
57+
scope.destroy();
58+
expect(element).toHaveText('INNER()');
59+
}));
60+
}));
61+
62+
forAllCompilersAndComponentFactories(() =>
3663
describe('dte.compiler', () {
3764
TestBed _;
3865

0 commit comments

Comments
 (0)