Skip to content

Commit

Permalink
suggested solution in #73 implemented as pull request
Browse files Browse the repository at this point in the history
  • Loading branch information
k2s committed May 24, 2014
1 parent 5fd133b commit e3f08b5
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
20 changes: 18 additions & 2 deletions dist/IndexedDBShim.js
Expand Up @@ -4,6 +4,22 @@
* An initialization file that checks for conditions, removes console.log and warn, etc
*/
var idbModules = {};

var cleanInterface = false;
(function () {
var testObject = {test: true};
//Test whether Object.defineProperty really works.
if (Object.defineProperty) {
try {
Object.defineProperty(testObject, 'test',{enumerable:false});
if (testObject.test)
cleanInterface = true
} catch (e) {
//Object.defineProperty does not work as intended.
}
}
})();

/*jshint globalstrict: true*/
'use strict';
(function(idbModules) {
Expand Down Expand Up @@ -48,7 +64,7 @@ var idbModules = {};
this.length = 0;
this._items = [];
//Internal functions on the prototype have been made non-enumerable below.
if (Object.defineProperty) {
if (cleanInterface) {
Object.defineProperty(this, '_items', {
enumerable: false
});
Expand Down Expand Up @@ -87,7 +103,7 @@ var idbModules = {};
}
}
};
if (Object.defineProperty) {
if (cleanInterface) {
for (var i in {
'indexOf': false,
'push': false,
Expand Down
17 changes: 16 additions & 1 deletion src/Init.js
Expand Up @@ -3,4 +3,19 @@
/**
* An initialization file that checks for conditions, removes console.log and warn, etc
*/
var idbModules = {};
var idbModules = {};

var cleanInterface = false;
(function () {
var testObject = {test: true};
//Test whether Object.defineProperty really works.
if (Object.defineProperty) {
try {
Object.defineProperty(testObject, 'test',{enumerable:false});
if (testObject.test)
cleanInterface = true
} catch (e) {
//Object.defineProperty does not work as intended.
}
}
})();
4 changes: 2 additions & 2 deletions src/util.js
Expand Up @@ -42,7 +42,7 @@
this.length = 0;
this._items = [];
//Internal functions on the prototype have been made non-enumerable below.
if (Object.defineProperty) {
if (cleanInterface) {
Object.defineProperty(this, '_items', {
enumerable: false
});
Expand Down Expand Up @@ -81,7 +81,7 @@
}
}
};
if (Object.defineProperty) {
if (cleanInterface) {
for (var i in {
'indexOf': false,
'push': false,
Expand Down

0 comments on commit e3f08b5

Please sign in to comment.