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

Commit

Permalink
fix(transcluding_component_factory): fix content detach logic
Browse files Browse the repository at this point in the history
detachContent was finding the wrong end comment node and failing on assetion (in checked mode).
  • Loading branch information
pavelgj committed May 22, 2014
1 parent b691fd9 commit 3141d32
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/core_dom/transcluding_component_factory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class ContentPort {

var next;
for (next = _beginComment.nextNode;
next.nodeType != dom.Node.COMMENT_NODE && next.text != endCommentText;
next.nodeType != dom.Node.COMMENT_NODE || next.text != endCommentText;
next = _beginComment.nextNode) {
_childNodes.add(next);
next.remove();
Expand Down
27 changes: 27 additions & 0 deletions test/core_dom/compiler_spec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ forBothCompilers(fn) {
});
fn();
});
}

forAllCompilersAndComponentFactories(fn) {
forBothCompilers(fn);

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

void main() {
forBothCompilers(() =>
describe('TranscludingComponentFactory', () {
TestBed _;

beforeEachModule((Module m) {
return m
..bind(ComponentFactory, toImplementation: TranscludingComponentFactory)
..bind(SimpleComponent);
});

beforeEach(inject((TestBed tb) => _ = tb));

it('should correctly detach transcluded content when scope destroyed', async(() {
var scope = _.rootScope.createChild({});
var element = _.compile(r'<div><simple><span ng-if="true == true">trans</span></simple></div>', scope: scope);
microLeap();
_.rootScope.apply();
expect(element).toHaveText('INNER(trans)');
scope.destroy();
expect(element).toHaveText('INNER()');
}));
}));

forAllCompilersAndComponentFactories(() =>
describe('dte.compiler', () {
TestBed _;

Expand Down

0 comments on commit 3141d32

Please sign in to comment.