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

Cannot warn or use the previous DNodes when a supported DNode type of undefined is returned. #598

Merged
merged 1 commit into from
Jun 26, 2017
Merged
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
7 changes: 1 addition & 6 deletions src/WidgetBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -587,12 +587,7 @@ export class WidgetBase<P = WidgetProperties, C extends DNode = DNode> extends E
const afterRenders = this.getDecorator('afterRender');

return afterRenders.reduce((dNode: DNode | DNode[], afterRenderFunction: AfterRender) => {
const updatedDNode = afterRenderFunction.call(this, dNode);
if (!updatedDNode) {
console.warn('DNodes not returned from afterRender, using existing dNodes');
return dNode;
}
return updatedDNode;
return afterRenderFunction.call(this, dNode);
}, dNode);
}

Expand Down
17 changes: 0 additions & 17 deletions tests/unit/WidgetBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -777,23 +777,6 @@ registerSuite({
const widget = new TestWidget();
widget.__render__();
assert.strictEqual(afterRenderCount, 1);
},
'Use previous DNodes when an afterRender does not return DNodes'() {
class TestWidget extends WidgetBase {
@afterRender()
protected firstBeforeRender(dNode: DNode | DNode[]) {
return 'first render';
}

@afterRender()
protected secondBeforeRender(dNode: DNode | DNode[]) { }
}

const widget = new TestWidget();
const vNode = <VNode> widget.__render__();
assert.strictEqual(vNode, 'first render');
assert.isTrue(consoleStub.calledOnce);
assert.isTrue(consoleStub.calledWith('DNodes not returned from afterRender, using existing dNodes'));
}
},
'extendable'() {
Expand Down