Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MouseEvent is used from window in off-click #258

Open
dennisx5 opened this issue Jun 15, 2016 · 9 comments
Open

MouseEvent is used from window in off-click #258

dennisx5 opened this issue Jun 15, 2016 · 9 comments

Comments

@dennisx5
Copy link

The off-click uses MouseEvent which is an object from the global window. Angular2-modules should avoid direct access to window to be compatible with Angular-Universal and WebWorker.

When I started to use ng2-select with server-side-rendering of Angular-Universal I had errors like "MouseEvent is not defined" and had to define MouseEvent in nodes-global.

@hongbo-miao
Copy link

Link to valor-software/ngx-bootstrap#61

@linusbrolin
Copy link
Contributor

I'd say valor-software/ngx-bootstrap#964 is more relevant, since it seems the problem has re-appeared.
@valorkin fixed it in ng2-bootstrap with valor-software/ngx-bootstrap@d20ccf1

so the fix is to add these lines in off-click.ts:

/* tslint:disable-next-line */
const MouseEvent = (global as any).MouseEvent as MouseEvent;

@romansp
Copy link

romansp commented Mar 6, 2017

Can we get some love for this particular issue? That's one of the few things that blocks me from angular-universal server-side rendering.

I can do a dedicated PR, that does the same hack as valor-software/ngx-bootstrap@d20ccf1. Will it be useful?

@jessedegans
Copy link

jessedegans commented Jun 20, 2017

Please just fix this.

by adding this line:

/* tslint:disable-next-line */
const MouseEvent = (global as any).MouseEvent as MouseEvent;

@anas3636
Copy link

Hey guys

I have the same issue here ! is there any workaround ?
Where I am suppose to add this line ?
/* tslint:disable-next-line */
const MouseEvent = (global as any).MouseEvent as MouseEvent;
In the server or in the angular app!
Please help

@jessedegans
Copy link

You should add it to the top of the bundled ng2-select js file

@simonmlewis
Copy link

simonmlewis commented Sep 1, 2017

Hi @jessedegans ,

Can your provide the exact filename that the "fix" code needs to be place please?

None of the files seem suitable so don't know if I'm missing something?

image

@graundas
Copy link

I found a temporary solution to this problem. I put a text replacing plugin regexp-replace-loader to webpack config:

  module: {
    rules: [
      { test: /\.(ts|js)$/, loader: 'regexp-replace-loader', options: { match: { pattern: '\\[(Mouse|Keyboard)Event\\]', flags: 'g' }, replaceWith: '[]', } },
      { test: /\.ts$/, loader: 'ts-loader' },
    ]
  },

@fopnet
Copy link

fopnet commented Feb 21, 2019

Please just fix this.

by adding this line:

/* tslint:disable-next-line */
const MouseEvent = (global as any).MouseEvent as MouseEvent;

I have inserted this line in

.../node_modules/angular2-multiselect-dropdown/clickOutside.d.ts after the imports line but the same error is thrown !

After angular universal compilation in this command below.

ngu-sw-manifest --module src/app/app.module.ts --out dist/ngsw-manifest.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants