Skip to content

Commit

Permalink
fix(runtime): correctly set isWatchReady flag for custom elements build
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley committed Jun 30, 2020
1 parent 61a6982 commit 36b4978
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
8 changes: 5 additions & 3 deletions src/runtime/initialize-component.ts
Expand Up @@ -12,10 +12,10 @@ import { createTime, uniqueTime } from './profile';
export const initializeComponent = async (elm: d.HostElement, hostRef: d.HostRef, cmpMeta: d.ComponentRuntimeMeta, hmrVersionId?: string, Cstr?: any) => {
// initializeComponent
if ((BUILD.lazyLoad || BUILD.hydrateServerSide || BUILD.style) && (hostRef.$flags$ & HOST_FLAGS.hasInitializedComponent) === 0) {
// we haven't initialized this element yet
hostRef.$flags$ |= HOST_FLAGS.hasInitializedComponent;

if (BUILD.lazyLoad || BUILD.hydrateClientSide) {
// we haven't initialized this element yet
hostRef.$flags$ |= HOST_FLAGS.hasInitializedComponent;

// lazy loaded components
// request the component's implementation to be
// wired up with the host element
Expand Down Expand Up @@ -66,7 +66,9 @@ export const initializeComponent = async (elm: d.HostElement, hostRef: d.HostRef
endNewInstance();
fireConnectedCallback(hostRef.$lazyInstance$);
} else {
// sync constructor component
Cstr = elm.constructor as any;
hostRef.$flags$ |= HOST_FLAGS.isWatchReady | HOST_FLAGS.hasInitializedComponent;
}

if (BUILD.style && Cstr.style) {
Expand Down
26 changes: 12 additions & 14 deletions src/runtime/set-value.ts
Expand Up @@ -47,21 +47,19 @@ export const setValue = (ref: d.RuntimeRef, propName: string, newVal: any, cmpMe

if (!BUILD.lazyLoad || instance) {
// get an array of method names of watch functions to call
if (BUILD.watchCallback && cmpMeta.$watchers$) {
if (!BUILD.lazyLoad || flags & HOST_FLAGS.isWatchReady) {
const watchMethods = cmpMeta.$watchers$[propName];
if (BUILD.watchCallback && cmpMeta.$watchers$ && flags & HOST_FLAGS.isWatchReady) {
const watchMethods = cmpMeta.$watchers$[propName];

if (watchMethods) {
// this instance is watching for when this property changed
watchMethods.map(watchMethodName => {
try {
// fire off each of the watch methods that are watching this property
instance[watchMethodName](newVal, oldVal, propName);
} catch (e) {
consoleError(e);
}
});
}
if (watchMethods) {
// this instance is watching for when this property changed
watchMethods.map(watchMethodName => {
try {
// fire off each of the watch methods that are watching this property
instance[watchMethodName](newVal, oldVal, propName);
} catch (e) {
consoleError(e);
}
});
}
}

Expand Down

0 comments on commit 36b4978

Please sign in to comment.