diff --git a/src/runtime/initialize-component.ts b/src/runtime/initialize-component.ts index 5b3edbe4b07..4dd77cf6867 100644 --- a/src/runtime/initialize-component.ts +++ b/src/runtime/initialize-component.ts @@ -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 @@ -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) { diff --git a/src/runtime/set-value.ts b/src/runtime/set-value.ts index abccc540b93..e91a6cd06e9 100644 --- a/src/runtime/set-value.ts +++ b/src/runtime/set-value.ts @@ -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); + } + }); } }