parent
116b64de25
commit
61c73576c8
|
@ -83,8 +83,10 @@ export class DomRenderer extends Renderer {
|
|||
attachFragmentAfterFragment(previousFragmentRef: RenderFragmentRef,
|
||||
fragmentRef: RenderFragmentRef) {
|
||||
var previousFragmentNodes = resolveInternalDomFragment(previousFragmentRef);
|
||||
var sibling = previousFragmentNodes[previousFragmentNodes.length - 1];
|
||||
moveNodesAfterSibling(sibling, resolveInternalDomFragment(fragmentRef));
|
||||
if (previousFragmentNodes.length > 0) {
|
||||
var sibling = previousFragmentNodes[previousFragmentNodes.length - 1];
|
||||
moveNodesAfterSibling(sibling, resolveInternalDomFragment(fragmentRef));
|
||||
}
|
||||
}
|
||||
|
||||
attachFragmentAfterElement(elementRef: RenderElementRef, fragmentRef: RenderFragmentRef) {
|
||||
|
@ -253,7 +255,7 @@ export class DomRenderer extends Renderer {
|
|||
}
|
||||
|
||||
function moveNodesAfterSibling(sibling, nodes) {
|
||||
if (isPresent(DOM.parentElement(sibling))) {
|
||||
if (nodes.length > 0 && isPresent(DOM.parentElement(sibling))) {
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
DOM.insertBefore(sibling, nodes[i]);
|
||||
}
|
||||
|
|
|
@ -197,6 +197,33 @@ export function main() {
|
|||
});
|
||||
}));
|
||||
|
||||
it('should add and remove empty fragments',
|
||||
inject([AsyncTestCompleter, DomTestbed], (async, tb: DomTestbed) => {
|
||||
tb.compileAndMerge(someComponent,
|
||||
[
|
||||
new ViewDefinition({
|
||||
componentId: 'someComponent',
|
||||
template: '<template></template><template></template>',
|
||||
directives: []
|
||||
})
|
||||
])
|
||||
.then((protoViewMergeMappings) => {
|
||||
var rootView = tb.createView(protoViewMergeMappings[0]);
|
||||
|
||||
var elr = elRef(rootView.viewRef, 1);
|
||||
expect(rootView.hostElement).toHaveText('');
|
||||
var fragment = rootView.fragments[1];
|
||||
var fragment2 = rootView.fragments[2];
|
||||
tb.renderer.attachFragmentAfterElement(elr, fragment);
|
||||
tb.renderer.attachFragmentAfterFragment(fragment, fragment2);
|
||||
tb.renderer.detachFragment(fragment);
|
||||
tb.renderer.detachFragment(fragment2);
|
||||
expect(rootView.hostElement).toHaveText('');
|
||||
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should handle events', inject([AsyncTestCompleter, DomTestbed], (async, tb: DomTestbed) => {
|
||||
tb.compileAndMerge(someComponent,
|
||||
[
|
||||
|
|
Loading…
Reference in New Issue