Skip to content

Commit

Permalink
Code Completion in VS2013 broken in Dexie v1.1
Browse files Browse the repository at this point in the history
Ever since commit 722aa20 that resolved
#76 (Web Worker support), the code completion when using Dexie in Visual
Studio has been broken.

The reason was that 'window' was replaced with 'self' to support
WebWorker environment. But self is not handled by VS intellisense
engine. To work around this, 'self' is replaced with 'self || window'
and the nice intellicense came back to live...
  • Loading branch information
dfahlander committed Apr 20, 2015
1 parent 813930b commit cf0bf70
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
8 changes: 4 additions & 4 deletions addons/Dexie.Observable/Dexie.Observable.js
Original file line number Diff line number Diff line change
Expand Up @@ -799,17 +799,17 @@
});
}).apply(null,
// AMD:
typeof define === 'function' && define.amd ? [self, define] :
typeof define === 'function' && define.amd ? [self || window, define] :
// CommonJS:
typeof global !== 'undefined' && typeof module !== 'undefined' && typeof require != 'undefined' ?
[global, function (name, modules, fn) {
module.exports = fn.apply(null, modules.map(function(id) { return require(id); }));
}] :
// Vanilla HTML and WebWorkers:
[self, function (name, modules, fn) {
var addon = fn.apply(null,modules.map(function(m){return m.split('.').reduce(function(p,c){return p&&p[c];},self);})),
[self || window, function (name, modules, fn) {
var addon = fn.apply(null,modules.map(function(m){return m.split('.').reduce(function(p,c){return p&&p[c];},self || window);})),
path = name.split('.'),
nsHost = path.slice(0,path.length-1).reduce(function(p,c){return p&&p[c];},self);
nsHost = path.slice(0,path.length-1).reduce(function(p,c){return p&&p[c];},self || window);
Dexie.addons.push(addon);
nsHost[path[path.length-1]] = addon;
}]
Expand Down
8 changes: 4 additions & 4 deletions addons/Dexie.Syncable/Dexie.Syncable.js
Original file line number Diff line number Diff line change
Expand Up @@ -1010,17 +1010,17 @@

}).apply(null,
// AMD:
typeof define === 'function' && define.amd ? [self, define] :
typeof define === 'function' && define.amd ? [self || window, define] :
// CommonJS:
typeof global !== 'undefined' && typeof module !== 'undefined' && typeof require != 'undefined' ?
[global, function (name, modules, fn) {
module.exports = fn.apply(null, modules.map(function (id) { return require(id); }));
}] :
// Vanilla HTML and WebWorkers:
[self, function (name, modules, fn) {
var addon = fn.apply(null, modules.map(function (m) { return m.split('.').reduce(function (p, c) { return p && p[c]; }, self); })),
[self || window, function (name, modules, fn) {
var addon = fn.apply(null, modules.map(function (m) { return m.split('.').reduce(function (p, c) { return p && p[c]; }, self || window); })),
path = name.split('.'),
nsHost = path.slice(0, path.length - 1).reduce(function (p, c) { return p && p[c]; }, self);
nsHost = path.slice(0, path.length - 1).reduce(function (p, c) { return p && p[c]; }, self || window);
Dexie.addons.push(addon);
nsHost[path[path.length - 1]] = addon;
}]
Expand Down
9 changes: 4 additions & 5 deletions addons/Dexie.Yield/Dexie.Yield.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
// Don't accept yielding a non-promise such as "yield 3;".
// By not accepting that, we could detect bugs better.
iterable.throw(new TypeError("Only acceptable to yield a Promise"));

return next.value.then(onSuccess, onError);
}
}
Expand Down Expand Up @@ -78,17 +77,17 @@

}).apply(null,
// AMD:
typeof define === 'function' && define.amd ? [self, define] :
typeof define === 'function' && define.amd ? [self || window, define] :
// CommonJS:
typeof global !== 'undefined' && typeof module !== 'undefined' && typeof require != 'undefined' ?
[global, function (name, modules, fn) {
module.exports = fn.apply(null, modules.map(function (id) { return require(id); }));
}] :
// Vanilla HTML and WebWorkers:
[self, function (name, modules, fn) {
var addon = fn.apply(null, modules.map(function (m) { return m.split('.').reduce(function (p, c) { return p && p[c]; }, self); })),
[self || window, function (name, modules, fn) {
var addon = fn.apply(null, modules.map(function (m) { return m.split('.').reduce(function (p, c) { return p && p[c]; }, self || window); })),
path = name.split('.'),
nsHost = path.slice(0, path.length - 1).reduce(function (p, c) { return p && p[c]; }, self);
nsHost = path.slice(0, path.length - 1).reduce(function (p, c) { return p && p[c]; }, self || window);
Dexie.addons.push(addon);
nsHost[path[path.length - 1]] = addon;
}]
Expand Down
4 changes: 2 additions & 2 deletions src/Dexie.js
Original file line number Diff line number Diff line change
Expand Up @@ -3159,12 +3159,12 @@

// AMD:
typeof define === 'function' && define.amd ?
[self, function (name, value) { define(name, function () { return value; }); }] :
[self || window, function (name, value) { define(name, function () { return value; }); }] :

// CommonJS:
typeof global !== 'undefined' && typeof module !== 'undefined' && module.exports ?
[global, function (name, value) { module.exports = value; }]

// Vanilla HTML and WebWorkers:
: [self, function (name, value) { self[name] = value; }]);
: [self || window, function (name, value) { (self || window)[name] = value; }]);

0 comments on commit cf0bf70

Please sign in to comment.