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

Details disclosure element <details> adds and removes "open" attribute outside of incrementalDOM #465

Closed
mmzeeman opened this issue Jun 8, 2021 · 2 comments

Comments

@mmzeeman
Copy link

mmzeeman commented Jun 8, 2021

Incremental DOM does not see element attribute changes made by external libraries. In some way, the <details> element behaves like an external library, because clicks on it will toggle an open attribute on the element. Incremental DOM does not see the attribute changes.

Usually this behaviour is ok, because it allows one to open and close a details element without having to manage the state with javascript. This is possible by not putting "open" attributes in the element when rendering. That way Incremental DOM will not cache the "open" attribute and leave the state handling to the browser.

However... When the details element is already on the page, and the nodes not yet imported by Incremental DOM, it will cache the "open" attribute for any details summary field the user has openend. Those detail elements will be closed the next time the elements are rendered.

Is it possible to not cache the "open" attribute, and let that attribute be set and unset by the browser?

@mmzeeman
Copy link
Author

mmzeeman commented Jun 8, 2021

The details element is the only element I know which changes its own dom representation.

@mmzeeman mmzeeman changed the title Details disclosure element <details> adds and removes "open" outside of incrementalDOM Details disclosure element <details> adds and removes "open" attribute outside of incrementalDOM Jun 8, 2021
@mmzeeman
Copy link
Author

mmzeeman commented Jun 9, 2021

It turns out was possible to solve this issue by adding a special attribute handler.

IncrementalDOM.attributes["open"] = function(el, name, value) {}

@mmzeeman mmzeeman closed this as completed Jun 9, 2021
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