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

Decorated private class fields lead to seemingly unrelated failures in decorated private methods #1

Closed
SirPepe opened this issue Aug 31, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@SirPepe
Copy link
Owner

SirPepe commented Aug 31, 2023

To reproduce:

@define("test-el")
class Test extends HTMLElement {
  @debounce({ fn: debounce.timeout(0) }) #a = () => {};
  @reactive() #test() {}
}
new Test();

The exception Attempted to access private element on non-instance occurs when the initializer for @reactive() performs context.access.get(this). This can be fixed once babel has been updated to support context.addInitializer in class fields, see tc39/proposal-decorators#508 (comment)

Until then, either the method or the field can't be private.

@SirPepe SirPepe added the bug Something isn't working label Aug 31, 2023
@SirPepe SirPepe self-assigned this Aug 31, 2023
SirPepe added a commit that referenced this issue Aug 31, 2023
@SirPepe
Copy link
Owner Author

SirPepe commented Mar 6, 2024

Babel now supports context.addInitializer() for class fields, but they run at the wrong time: babel/babel#16188

This remains broken for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant