diff --git a/lib/mixins/property-effects.html b/lib/mixins/property-effects.html
index 2321826b7e..6aca39fe9a 100644
--- a/lib/mixins/property-effects.html
+++ b/lib/mixins/property-effects.html
@@ -185,12 +185,12 @@
* @private
*/
function runObserverEffect(inst, property, props, oldProps, info) {
- let fn = inst[info.methodName];
+ let fn = typeof info.method === 'function' ? info.method : inst[info.method];
let changedProp = info.property;
if (fn) {
fn.call(inst, inst.__data[changedProp], oldProps[changedProp]);
} else {
- console.warn('observer method `' + info.methodName + '` not defined');
+ console.warn('observer method `' + info.method + '` not defined');
}
}
@@ -1899,19 +1899,19 @@
* Creates a single-property observer for the given property.
*
* @param {string} property Property name
- * @param {string} methodName Name of observer method to call
+ * @param {string|function(*,*)} method Name or function reference of observer method to call
* @param {boolean=} dynamicFn Whether the method name should be included as
* a dependency to the effect.
* @protected
*/
- _createPropertyObserver(property, methodName, dynamicFn) {
- let info = { property, methodName };
+ _createPropertyObserver(property, method, dynamicFn) {
+ let info = { property, method };
this._addPropertyEffect(property, TYPES.OBSERVE, {
fn: runObserverEffect, info, trigger: {name: property}
});
if (dynamicFn) {
- this._addPropertyEffect(methodName, TYPES.OBSERVE, {
- fn: runObserverEffect, info, trigger: {name: methodName}
+ this._addPropertyEffect(method, TYPES.OBSERVE, {
+ fn: runObserverEffect, info, trigger: {name: method}
});
}
}
diff --git a/test/unit/property-effects-elements.html b/test/unit/property-effects-elements.html
index 7005ec55b3..6b1e0d4c19 100644
--- a/test/unit/property-effects-elements.html
+++ b/test/unit/property-effects-elements.html
@@ -433,6 +433,7 @@