mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-28 18:47:41 +00:00
Let global inherit from self in Node.JS.
This commit is contained in:
parent
a1b3be77e3
commit
7839a50e16
3 changed files with 13 additions and 4 deletions
|
|
@ -287,7 +287,7 @@ TODO
|
|||
|
||||
- [ ] Change `context` to `contexts`.
|
||||
- [ ] Figure out what a `Context` will be
|
||||
- [ ] Implement hack to make `global` inherit from `self`
|
||||
- [x] Implement hack to make `global` inherit from `self`
|
||||
- [ ] Define on `self.registerModel(m: Model)` protocol
|
||||
- [ ] Describe `contexts`
|
||||
- [ ] make simple `index.html` that demos a dummy model
|
||||
|
|
|
|||
10
lmlayer.js
10
lmlayer.js
|
|
@ -65,4 +65,14 @@ function loadModelClass() {
|
|||
return global.Model;
|
||||
}
|
||||
|
||||
/**
|
||||
* HACK: on Node.JS + tiny-worker, ensure code imported with importScripts()
|
||||
* has access to the same things defined on self in this file.
|
||||
*/
|
||||
if (typeof global !== 'undefined') {
|
||||
let globalPrototype = Object.getPrototypeOf(global);
|
||||
Object.setPrototypeOf(self, globalPrototype);
|
||||
Object.setPrototypeOf(global, self);
|
||||
}
|
||||
|
||||
/*global importScripts*/
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ class Model {
|
|||
}
|
||||
|
||||
// TODO: shouldn't this be running in the same scope as the original?
|
||||
// TODO: test in a browser!
|
||||
if (typeof global !== 'undefined') {
|
||||
global.Model = Model;
|
||||
}
|
||||
global.Model = Model;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue