Permalink
Browse files

Fix __defineSetter__ & __defineGetter__ issued by IE9

  • Loading branch information...
1 parent ca38084 commit db8b2f73a28cd64d52548e99caba9e9477b937e4 @budiadiono committed Oct 4, 2012
Showing with 33 additions and 11 deletions.
  1. +33 −11 lib/persistence.js
View
@@ -28,11 +28,23 @@ if (typeof exports !== 'undefined') {
return initPersistence({})
}
var singleton;
- exports.__defineGetter__("persistence", function () {
- if (!singleton)
- singleton = exports.createPersistence();
- return singleton;
- });
+ if (typeof (exports.__defineGetter__) === 'function') {
+ exports.__defineGetter__("persistence", function () {
+ if (!singleton)
+ singleton = exports.createPersistence();
+ return singleton;
+ });
+ } else {
+ Object.defineProperty(exports, "persistence", {
+ get: function () {
+ if (!singleton)
+ singleton = exports.createPersistence();
+ return singleton;
+ },
+ enumerable: true, configurable: true
+ });
+ }
+
}
else {
window = window || {};
@@ -55,12 +67,22 @@ persistence.isImmutable = function(fieldName) {
* Default implementation for entity-property
*/
persistence.defineProp = function(scope, field, setterCallback, getterCallback) {
- scope.__defineSetter__(field, function (value) {
- setterCallback(value);
- });
- scope.__defineGetter__(field, function () {
- return getterCallback();
- });
+ if (typeof (scope.__defineSetter__) === 'function' && typeof (scope.__defineGetter__) === 'function') {
+ scope.__defineSetter__(field, function (value) {
+ setterCallback(value);
+ });
+ scope.__defineGetter__(field, function () {
+ return getterCallback();
+ });
+ } else {
+ Object.defineProperty(scope, field, {
+ get: getterCallback,
+ set: function (value) {
+ setterCallback(value);
+ },
+ enumerable: true, configurable: true
+ });
+ }
};
/**

0 comments on commit db8b2f7

Please sign in to comment.