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

Custom Events support in lwc:spread throws unknown public property error #4545

Open
Templarian opened this issue Sep 10, 2024 · 2 comments
Open

Comments

@Templarian
Copy link
Contributor

Description

Using lwc:spread={apis} with onclick works since it's a global property, but custom events won't work. Ex: onbar.

Steps to Reproduce

https://stackblitz.com/edit/salesforce-lwc-qhg5sq?file=src%2Fmodules%2Fx%2Fapp%2Fapp.html,src%2Fmodules%2Fx%2Fapp%2Fapp.js

<lwc:component lwc:is={component} lwc:spread={apis}></lwc:component>

Expected Results

The event firing from the dynamic component should trigger the onbar function passed into lwc:spread object.

Actual Results

Error: [LWC warn]: Unknown public property "onbar" of element <x-dynamic>. This is either a typo on the corresponding attribute "onbar", or the attribute does not exist in this browser or DOM implementation.

Browsers Affected

All.

Version

  • LWC: 8

Possible Solution

Probably to manually addEventListener each of the on prefixed keys in the object. Don't know if onclick and global ones like it need to be ignored?

Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.

@nolanlawson
Copy link
Collaborator

Related: #4425

@Templarian
Copy link
Contributor Author

const foo = Symbol('foo');
//... inside of class
apis = {
    [foo]: 'some value only accessible by knowing foo';
};
<lwc:component lwc:is={component} lwc:spread={apis}></lwc:component>

I don't have a use for this, but did notice that symbols are also not binded to the host element with lwc:spread. So it doesn't look to be binding all keys, possibly only keys with a string type.

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

No branches or pull requests

2 participants