function getSetter(name, kind, opt_setHook) {
    switch (kind) {
      case PropertyKind.JS:
        let privateName = name + '_';
        return function (value) {
          let oldValue = this[name];
          if (value !== oldValue) {
            this[privateName] = value;
            if (opt_setHook) opt_setHook.call(this, value, oldValue);
            dispatchPropertyChange(this, name, value, oldValue);
          }
        };

      case PropertyKind.ATTR:
        attributeName = getAttributeName(name);
        return function (value) {
          let oldValue = this[name];
          if (value !== oldValue) {
            if (value == undefined) this.removeAttribute(attributeName);
            else this.setAttribute(attributeName, value);
            if (opt_setHook) opt_setHook.call(this, value, oldValue);
            dispatchPropertyChange(this, name, value, oldValue);
          }
        };

      case PropertyKind.BOOL_ATTR:
        let attributeName = getAttributeName(name);
        return function (value) {
          let oldValue = this[name];
          if (value !== oldValue) {
            if (value) this.setAttribute(attributeName, name);
            else this.removeAttribute(attributeName);
            if (opt_setHook) opt_setHook.call(this, value, oldValue);
            dispatchPropertyChange(this, name, value, oldValue);
          }
        };
    }
  }
Helper function for defineProperty that returns the setter of the right
kind.
@param {string} name The name of the property we are defining the setter
    for.
@param {cr.PropertyKind} kind The kind of property we are getting the
    setter for.
@param {function(*):void} opt_setHook 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.