-
-
Notifications
You must be signed in to change notification settings - Fork 937
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
cannot add 'draggable' attr to img #383
Comments
Yeah it's an annoying property: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/draggable Basically it looks like boolean but isn't boolean. I'm not going to mess too much here. Just fix the types. I compile <img draggable={false} />
// to
el.setAttribute("draggable", false) Which doesn't work.. which IMHO just dumb. Know what does work according to the doc: el.setAttribute("draggable", "false")
// or
<img draggable="false" /> I'm pretty sure this is why React toStrings everything but also why it completely breaks web components. Draggable isn't worth it. I'm going to fix the types to reflect that draggable takes strings. |
No I found a better fix. Looked at what Svelte does. I will get this working in the next version. |
Should be fixed in 0.25.0. Reopen if still an issue. (keep in mind playground isn't updated yet) |
There is breaking change after upgrading from ^0.24.1 to 0.25.0 I have such code
if props.isLoading is false, before upgrading, there is no |
Oh right yes. This is caused by this very fix. I followed suite with other frameworks. We set strings on attributes now on |
well, in my opinion, the previous behaviour is more nature: boolean to toggle the attr and string is what as it is. I don't know if there is spec guiding other framework to do so. |
The problem is it isn't just draggable. It's any boolean non-boolean. There are a number of these properties. Boolean attributes are treated differently, unfortunately. This means in terms of custom properties like What I wrote earlier wasn't a hundred percent true. My helper checking for false and removing the attributes. But it was from a time before I was detecting boolean attributes properly. Calling So from that perspective it seems really reasonable this is what other frameworks do and it basically reflects how the DOM works, and why it seems like the logical choice here. |
I found lit-html creates a new syntax |
That's interesting. The closest we could do is namespace as JSX identifiers can't have special symbols other than $. Like |
I'm still facing an issue with
Is it intended or in the future, it can be improved to a bit more common:
|
@TrueMrMaverick It used to work that way but it causes problems for other "boolean non-booleans" (as I'm calling them now). The decision was to follow what the browser does rather than force it one way and having no way to force it the other way. Following browser conventions while less consistent avoid a lot of headaches later when you are now responsible for any edge cases. |
@ryansolid thanks for such a quick response! |
I'm saying we follow browser standards on things.. like if draggable isn't a boolean property.. ex Chrome, Firefox, and Safari doesn't support: <div draggable /> We aren't going to support it. Generally speaking on native elements we follow attribute conventions of the browser. So you can just refer to MDN docs to know what or how they work. React and some of the other frameworks sort of tried to normalize this stuff, but years later we're now trying to undo that work because it leads to equally inconsistent (and often less documented) behaviors. |
IMPORTANT: If you have a question or an idea for a new feature use Github Discussions instead
Describe the bug
this is no effect when adding
draggable
attr to img.To Reproduce
see https://playground.solidjs.com/#NobwRAlgJmBcYBYCuBTANhtBbAzlAVgAwAOAZgHYBsAFgOzlrWlgA0Y5AhlinGFhxHKswAFwCexHvBE4AHsJwB7JACcAxlMhZiilSIAEIfSpTkoKFfoC++0isVZ9AciVpoAWnw4A9AHcUAEZOANwAOuQQ2roGRmomHCIoAMoQAOacaNa29o4uim5Qnjgh4eGkSORqIhCK5PoAwsrkiSoAFACUhuH6xigiqnWt3T36ADyRqfo46gC8oWDUIiLEOLDe3sRoHGKp9hVQAHSu0F4Hag7eHDg4fT5oiqmKBwCMAEwAzAGECAFqRwBuqXm+l80BE1DmYFeCGB1BQaUWkOhwKgKg4qVSHACaBQMxApA4aBuNm8AD5hu0wuQrKVyCYzBZWh19DNSWNGhUWvoySx9FBFGokNxmgdUn0AKI44UiABCYgAklBWk4OMRiE52u1wmArABdIA
Expected behavior
cannot drag img
Reproduction
The text was updated successfully, but these errors were encountered: