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

Decorator Core Plugin is executed twice if gondel is present in multiple js files #48

Closed
janwidmer opened this issue Jul 12, 2019 · 3 comments
Assignees

Comments

@janwidmer
Copy link
Contributor

Type of issue

  • Bug report

The issue refers to:

  • the gondel core

Expected behavior

Loading the gondel core library multiple times should still trigger a click event only once per click.

Current behavior

If the gondel core library is loaded multiple times a click event is fired multiple times for a single click.

The reason for this bug is the GondelDecorators plugin which hooks itself multiple times in the start event.

There is already a code which tries to prevent this bug however it uses a local variable which will not prevent the bug if gondel is included in multiple different files:
https://github.com/namics/gondel/blob/b00e01157f11b8eb886f6b11d4d8f22d02d00bb3/packages/core/src/GondelDecorators.ts#L23

Steps to reproduce the behavior

  1. Include gondel/core twice
  2. Create a simple button component with a click listener.
  3. Click the button
  4. You will see that the click listener is fired twice

Possible solution:

Use a global window variable instead of a local variable

@janwidmer janwidmer self-assigned this Jul 12, 2019
@janbiasi
Copy link
Contributor

Why should you even include gondel multiple times? Just want to figure out the environment of this issue ..

@janwidmer
Copy link
Contributor Author

janwidmer commented Jul 15, 2019

I knew that question will come.. ;-) imagine nitro with some prototype js including a button to trigger an overlay on it's demo page..the button was done as gondel component and included in the proto.js entrypoint..that leads to it containing a second gondel core..

Of course the button could be done as plain js which also works..

janwidmer pushed a commit that referenced this issue Jul 25, 2019
…different js files

BREAKING CHANGE: enhances structure of pluginEvents object to track if a plugin (in another js file) has already been initialized

closes issue #48
jantimon pushed a commit that referenced this issue Jul 29, 2019
…different js files

BREAKING CHANGE: enhances structure of pluginEvents object to track if a plugin (in another js file) has already been initialized

closes issue #48
jantimon pushed a commit that referenced this issue Jul 29, 2019
…different js files

BREAKING CHANGE: enhances structure of pluginEvents object to track if a plugin (in another js file) has already been initialized

closes issue #48
@janwidmer
Copy link
Contributor Author

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

Successfully merging a pull request may close this issue.

2 participants