Skip to content

Commit

Permalink
fix(runtime): schedule update when value change in ref()
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley committed May 21, 2020
1 parent 215805c commit 54ee75f
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/runtime/update-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,8 @@ const dispatchHooks = (hostRef: d.HostRef, isInitialLoad: boolean) => {
}

endSchedule();
return then(promise, () => (
updateComponent(hostRef, instance, isInitialLoad)
));
}
return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
};

const updateComponent = (hostRef: d.HostRef, instance: any, isInitialLoad: boolean) => {
// updateComponent
Expand All @@ -88,9 +86,9 @@ const updateComponent = (hostRef: d.HostRef, instance: any, isInitialLoad: boole
// looks like we've got child nodes to render into this host element
// or we need to update the css class/attrs on the host element
// DOM WRITE!
renderVdom(hostRef, callRender(instance));
renderVdom(hostRef, callRender(hostRef, instance));
} else {
elm.textContent = callRender(instance);
elm.textContent = callRender(hostRef, instance);
}
}
if (BUILD.cssVarShim && plt.$cssShim$) {
Expand All @@ -100,9 +98,6 @@ const updateComponent = (hostRef: d.HostRef, instance: any, isInitialLoad: boole
hostRef.$renderCount$++;
hostRef.$flags$ &= ~HOST_FLAGS.devOnRender;
}
if (BUILD.updatable && BUILD.taskQueue) {
hostRef.$flags$ &= ~HOST_FLAGS.isQueuedForUpdate;
}

if (BUILD.hydrateServerSide) {
try {
Expand All @@ -122,9 +117,6 @@ const updateComponent = (hostRef: d.HostRef, instance: any, isInitialLoad: boole
}
}

if (BUILD.updatable || BUILD.lazyLoad) {
hostRef.$flags$ |= HOST_FLAGS.hasRendered;
}
if (BUILD.asyncLoading && rc) {
// ok, so turns out there are some child host elements
// waiting on this parent element to load
Expand Down Expand Up @@ -153,10 +145,18 @@ const updateComponent = (hostRef: d.HostRef, instance: any, isInitialLoad: boole

let renderingRef: any = null;

const callRender = (instance: any) => {
const callRender = (hostRef: d.HostRef, instance: any) => {
try {
renderingRef = instance;
instance = BUILD.allRenderFn ? instance.render() : instance.render && instance.render();

if (BUILD.updatable && BUILD.taskQueue) {
hostRef.$flags$ &= ~HOST_FLAGS.isQueuedForUpdate;
}

if (BUILD.updatable || BUILD.lazyLoad) {
hostRef.$flags$ |= HOST_FLAGS.hasRendered;
}
} catch (e) {
consoleError(e);
}
Expand Down

0 comments on commit 54ee75f

Please sign in to comment.