Skip to content

Commit

Permalink
fix: rerender legacy compatibility components
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey committed Aug 1, 2019
1 parent 238eada commit ad3f90b
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/index-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ export async function render<T extends Template>(
)
)) as any;

const isV3 = !renderResult.getComponent;
const isV4 = renderResult.getComponent;
const instance = renderResult
.appendTo(container)
[isV3 ? /* istanbul ignore next */ "getWidget" : "getComponent"]();
[isV4 ? "getComponent" : /* istanbul ignore next */ "getWidget"]();
const eventRecord: EventRecord = {};
mountedComponents.add({ container, instance, isDefaultContainer });

Expand Down Expand Up @@ -78,22 +78,23 @@ export async function render<T extends Template>(
},
rerender(newInput?: typeof input): Promise<void> {
return new Promise(resolve => {
/* istanbul ignore if */
if (isV3) {
instance.once("render", () => resolve());
instance.once(
isV4 ? "update" : /* istanbul ignore next */ "render",
() => resolve()
);

if (newInput) {
if (newInput) {
if (instance.setProps) {
instance.setProps(newInput);
} else {
instance.setStateDirty("__forceUpdate__");
instance.input = newInput;
}
} else {
instance.once("update", () => resolve());

if (newInput) {
instance.input = newInput;
} else {
/* istanbul ignore else */
if (instance.forceUpdate) {
instance.forceUpdate();
} else {
instance.setStateDirty("__forceUpdate__");
}
}
});
Expand Down

0 comments on commit ad3f90b

Please sign in to comment.