mirror of
https://ark.sudovanilla.org/Korbs/electron-tabs.git
synced 2024-12-23 03:53:53 +00:00
Merge pull request #120 from toddtarsi/work-without-node-anything
feat: work without any nodeIntegration requirements
This commit is contained in:
commit
55d1f1a492
|
@ -23,7 +23,6 @@ Electron-tabs uses webviews, so you first need to use the following `webPreferen
|
||||||
```js
|
```js
|
||||||
const mainWindow = new electron.BrowserWindow({
|
const mainWindow = new electron.BrowserWindow({
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
nodeIntegration: true,
|
|
||||||
webviewTag: true
|
webviewTag: true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,7 +4,6 @@ const app = electron.app;
|
||||||
app.on('ready', function () {
|
app.on('ready', function () {
|
||||||
const mainWindow = new electron.BrowserWindow({
|
const mainWindow = new electron.BrowserWindow({
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
nodeIntegration: true,
|
|
||||||
webviewTag: true
|
webviewTag: true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
15
index.js
15
index.js
|
@ -1,5 +1,3 @@
|
||||||
const EventEmitter = require("events");
|
|
||||||
|
|
||||||
if (!document) {
|
if (!document) {
|
||||||
throw Error("electron-tabs module must be called in renderer process");
|
throw Error("electron-tabs module must be called in renderer process");
|
||||||
}
|
}
|
||||||
|
@ -22,6 +20,19 @@ if (!document) {
|
||||||
document.getElementsByTagName("head")[0].appendChild(styleTag);
|
document.getElementsByTagName("head")[0].appendChild(styleTag);
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This makes the browser EventTarget API work similar to EventEmitter
|
||||||
|
*/
|
||||||
|
class EventEmitter extends EventTarget {
|
||||||
|
emit (type, ...args) {
|
||||||
|
this.dispatchEvent(new CustomEvent(type, { detail: args }));
|
||||||
|
}
|
||||||
|
|
||||||
|
on (type, fn) {
|
||||||
|
this.addEventListener(type, ({ detail }) => fn.apply(this, detail));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class TabGroup extends EventEmitter {
|
class TabGroup extends EventEmitter {
|
||||||
constructor (args = {}) {
|
constructor (args = {}) {
|
||||||
super();
|
super();
|
||||||
|
|
Loading…
Reference in a new issue