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

Component recycling problematic for username/password input elements #1208

Closed
AlexVallat opened this issue Sep 12, 2018 · 8 comments
Closed
Labels

Comments

@AlexVallat
Copy link

Preact will recycle a component if it can, and I can find no supported way to disable this behaviour. This is causing a problem for username/password input elements. Chrome will correctly auto-fill a username/password pair. If, as a result of pressing a "login" button, for example, these components are then removed and a new set of components created which also happen to contain input elements for other purposes, the username/password components and input elements will be reused.

This results in Chrome believing they are the same input elements (which of course, technically, they are) and continuing to autofill the username and password into them. Even if they aren't even a password box any more (exposing the password as plaintext)

@marvinhagemeister
Copy link
Member

Just an FYI: We have removed component recycling completely for the next major version. We don't have a time estimate for a release though.

@developit
Copy link
Member

Yup. The workaround for now is this shim that disables recycling for a component:

https://gist.github.com/developit/fa084f3cb38778f93d58607377f416a3

@AlexVallat
Copy link
Author

Ah, I didn't realise .__b could be relied on, so my workaround was to search all properties for one whose value was set to what .base used to be, and null that one! Thanks for confirming that it's on your radar for the next release.

@kevinfarrugia
Copy link

kevinfarrugia commented Sep 12, 2018

What is the exact difference between element recycling (which was removed in version 8) and component recycling? I couldn't find documentation on either and expected the above issue to have been solved in version 8.

@developit
Copy link
Member

developit commented Oct 10, 2018

Element recycling: removed/unrendered DOM elements we placed into a pool for later re-use.

Component recycling: the last known DOM tree for removed/unrendered Components is placed into a pool and reused when a new instance of that component is mounted.

The reason this is taking a while to get out is because Preact's current renderer relies on Component recycling for performance. It was possible to avoid doing so, but it required rewriting the renderer (which we've now done).

@mingard
Copy link

mingard commented Oct 31, 2018

Would it be correct to assume that if one were to creating a slightly modified version of the user/pass components, limiting their usage to the login form e.g.

<TextInputUser />
<TextInputPass />

The components would not be recycled?

@kevinfarrugia
Copy link

Would it be correct to assume that if one were to creating a slightly modified version of the user/pass components, limiting their usage to the login form e.g.

<TextInputUser />
<TextInputPass />

The components would not be recycled?

This had worked for us, but if you would use the same components on a forgot password form or a create account then you risk encountering the issue again.

Using the gist workaround posted by @developit worked well in all scenarios and personally I wouldn't recommend any other option.

@marvinhagemeister
Copy link
Member

We just merged the code for our next version of Preact #1302 and have some good news: The component recycler is no more 🎉

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

No branches or pull requests

5 participants