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

Web component's present attributes should be truthy #4518

Closed
1 task done
yoyomo opened this issue Sep 30, 2024 · 2 comments
Closed
1 task done

Web component's present attributes should be truthy #4518

yoyomo opened this issue Sep 30, 2024 · 2 comments
Labels
needs-more-info The issue doesn't contain enough information to be able to help

Comments

@yoyomo
Copy link

yoyomo commented Sep 30, 2024

  • Check if updating to the latest Preact version resolves the issue

Describe the bug
When I include a boolean attribute in a web component I expect it to be considered true, much like react does. For example, <my-web-component truthy-attribute ></my-web-component> , but instead I must always include a value truthy-attribute=true .

Note: I was looking into diff/props and I thought to open a pull request to handle undefined alongside null but had no way of trying it locally so not sure if it would have worked

@JoviDeCroock
Copy link
Member

This issue seemingly lacks a bit of context 😅 we ask for a reproduction for a reason, either provide us with a failing test in our test-suite (which is also a way to test your changes btw) or a stackblitz reproduction. When I write a test in our test-suite that renders <my-component the-truth /> I correctly see this translated to <my-component the-truth='true' /> in the DOM. Not sure what different behavior your are expecting here as the issue isn't describing that.

To make this actionable we'll need to get a reproduction with the actual/expected behavior defined, then we can have a conversation about expectations.

@JoviDeCroock JoviDeCroock added the needs-more-info The issue doesn't contain enough information to be able to help label Oct 1, 2024
@rschristian
Copy link
Member

Going to close this on out as we don't have enough information to go on.

As mentioned, here's a simple example of this working with render & renderToString:

import { render } from 'preact';
import { renderToString } from 'preact-render-to-string';

function App() {
	return <web-component truthy-attribute></my-web-component>;
}

render(<App />, document.getElementById('app')); // <web-component truthy-attribute="true"></web-component>
console.log(renderToString(<App />)); // <web-component truthy-attribute></web-component>

REPL

Always happy to reopen if you can point us in the right direction.

@rschristian rschristian closed this as not planned Won't fix, can't repro, duplicate, stale Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-more-info The issue doesn't contain enough information to be able to help
Projects
None yet
Development

No branches or pull requests

3 participants