Index: chrome/browser/resources/shared/js/cr.js |
diff --git a/chrome/browser/resources/shared/js/cr.js b/chrome/browser/resources/shared/js/cr.js |
index 6686269d897f1ddd7c7f396529506bdbf3e49e4b..3786d7568182213d6c8e6e24c254da3b6279dc35 100644 |
--- a/chrome/browser/resources/shared/js/cr.js |
+++ b/chrome/browser/resources/shared/js/cr.js |
@@ -170,9 +170,11 @@ const cr = (function() { |
* for. |
* @param {cr.PropertyKind} kind The kind of property we are getting the |
* setter for. |
+ * @param {function():void} opt_set_hook A function to run after the property |
+ * is set, but before the propertyChange event is fired. |
* @return {function(*):void} The function to use as a setter. |
*/ |
- function getSetter(name, kind) { |
+ function getSetter(name, kind, opt_set_hook) { |
arv (Not doing code reviews)
2011/02/03 21:52:08
opt_setHook
nduca
2011/02/04 01:31:32
Done.
|
switch (kind) { |
case PropertyKind.JS: |
var privateName = name + '_'; |
@@ -180,6 +182,8 @@ const cr = (function() { |
var oldValue = this[privateName]; |
if (value !== oldValue) { |
this[privateName] = value; |
+ if (opt_set_hook) |
+ opt_set_hook.apply(this); |
arv (Not doing code reviews)
2011/02/03 21:52:08
I was thinking that it should pass the new value f
nduca
2011/02/04 01:31:32
Done.
|
dispatchPropertyChange(this, name, value, oldValue); |
} |
}; |
@@ -189,6 +193,8 @@ const cr = (function() { |
var oldValue = this[name]; |
if (value !== oldValue) { |
this.setAttribute(name, value); |
+ if (opt_set_hook) |
+ opt_set_hook.apply(this); |
dispatchPropertyChange(this, name, value, oldValue); |
} |
}; |
@@ -201,6 +207,8 @@ const cr = (function() { |
this.setAttribute(name, name); |
else |
this.removeAttribute(name); |
+ if (opt_set_hook) |
+ opt_set_hook.apply(this); |
dispatchPropertyChange(this, name, value, oldValue); |
} |
}; |
@@ -213,9 +221,11 @@ const cr = (function() { |
* @param {!Object} The object to define the property for. |
* @param {string} The name of the property. |
* @param {cr.PropertyKind=} opt_kind What kind of underlying storage to use. |
- * @param {*} opt_defaultValue The default value. |
+ * @param {*} opt_default The default value. |
+ * @param {function():void} opt_set_hook A function to run after the property |
+ * is set, but before the propertyChange event is fired. |
*/ |
- function defineProperty(obj, name, opt_kind, opt_default) { |
+ function defineProperty(obj, name, opt_kind, opt_default, opt_set_hook) { |
if (typeof obj == 'function') |
obj = obj.prototype; |
@@ -231,7 +241,7 @@ const cr = (function() { |
} |
if (!obj.__lookupSetter__(name)) { |
- obj.__defineSetter__(name, getSetter(name, kind)); |
+ obj.__defineSetter__(name, getSetter(name, kind, opt_set_hook)); |
} |
} |