Skip to content

Commit

Permalink
fix(watch): fix watch callbacks in custom elements build
Browse files Browse the repository at this point in the history
Closes #2478
  • Loading branch information
adamdbradley committed Jun 3, 2020
1 parent 258f2ab commit d052fe4
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/runtime/set-value.ts
Expand Up @@ -47,19 +47,21 @@ 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$ && flags & HOST_FLAGS.isWatchReady) {
const watchMethods = cmpMeta.$watchers$[propName];
if (BUILD.watchCallback && cmpMeta.$watchers$) {
if (!BUILD.lazyLoad || (BUILD.lazyLoad && 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 d052fe4

Please sign in to comment.