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

Widget not deleted properly #2

Open
ghost opened this issue Jun 22, 2017 · 2 comments
Open

Widget not deleted properly #2

ghost opened this issue Jun 22, 2017 · 2 comments

Comments

@ghost
Copy link

ghost commented Jun 22, 2017

I'm using the widget inside a component that's shown or hidden in a form, and I found out that when I hide the container component, the recaptcha is still shows, but in the top-left corner, above anything else.
I solved this setting the restamp="true" in the container component, and modifying the detached method as follows:

  detached: function() {
    // TODO: remove event listener
    this.container.remove();
  },

Do you think it can be the correct approach?
Thanks
Andrea

@Zecat
Copy link
Owner

Zecat commented Jun 22, 2017

Hi, the initial problem is the recaptcha doesn't work inside shadow dom, so it is appended to the body in case it has a shadow root parent. So when you hide your form, the widget might no longer be inside.

You can use the hidden property that handles the work of hiding the in-body widget, ex:

<template is="dom-if" if="[[condition]]">
  <google-recaptcha hidden="[[!condition]]" ... ></google-recaptcha>
  ...
</template>

And you're right, the container has to be removed when detached, submit a PR if you want ;)

@Zecat
Copy link
Owner

Zecat commented Jun 22, 2017

Oops remove() is not supported on IE11. Maybe something like

this.container && Polymer.dom(Polymer.dom(this.container).parentNode).removeChild(this.container);

or after all it only has to be remove when in-body

this.inBody && this.container && document.body.removeChild(this.container);

I'm not sure, I did'nt test that code

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

1 participant