Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Changed getter and setter definitions #23

Closed
wants to merge 1 commit into from

2 participants

@giuliandrimba
Collaborator

The problem:

__defineGetter__ and __defineSetter__ were not working on IE9. Besides that, these methods are deprecated according to MDN: https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/defineSetter

Solution:

Use Object.defineProperty instead, as it is ES5 preferred syntax, and works on IE9. https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/defineProperty

@arboleya
Owner

Very nice, I'm going to merge it soon in the edge branch I'm working on.

Thank you :beers:

@arboleya arboleya was assigned
@arboleya
Owner

Since the weather has changed dramatically over the branches salad, I've merged this code manually as comments by now.
b88d5ab

In the very future, when the model will be re-implemented, things will stay tight.

Thank you.

@arboleya arboleya closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 26, 2013
  1. @giuliandrimba
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 4 deletions.
  1. +4 −2 lib/theoricus.js
  2. +1 −2  www/src/mvc/model.coffee
View
6 lib/theoricus.js
@@ -11275,8 +11275,10 @@ var theoricus = window.theoricus = {'config':{},'core':{},'mvc':{'lib':{}},'util
throw new Error(msg);
}
};
- this.prototype.__defineGetter__(field, getter);
- return this.prototype.__defineSetter__(field, setter);
+ return Object.defineProperty(this.prototype, field, {
+ get: getter,
+ set: setter
+ });
};
/*
View
3  www/src/mvc/model.coffee
@@ -77,8 +77,7 @@ class theoricus.mvc.Model extends theoricus.mvc.lib.Binder
msg = "Property '#{prop}' must to be #{stype}."
throw new Error msg
- @::.__defineGetter__ field, getter
- @::.__defineSetter__ field, setter
+ Object.defineProperty @::, field, get:getter, set:setter
Something went wrong with that request. Please try again.