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

Allow attr() helper method to receive false as value #52

Closed
jfelip937 opened this issue Apr 29, 2022 · 3 comments
Closed

Allow attr() helper method to receive false as value #52

jfelip937 opened this issue Apr 29, 2022 · 3 comments

Comments

@jfelip937
Copy link
Contributor

PROBLEM

With attributes that only their presense is checked (like disable) we can not remove them with the method attr().

PROPOSED SOLUTION

To be able to send false as value if we want to remove the attribute (in case that we want to set "false" as a attribute value we can send it as string):

attr(elem, "disabled", false)

Right now false has the same behaviour as null and it returns the attribute value.

ALTERNATIVE SOLUTION

New method to remove attributes. Still the other solution seems better to me as we can do things like attr(elem, "disabled", checkbox.checked).

@jfelip937 jfelip937 added enhancement New feature or request core labels Apr 29, 2022
@franpb14
Copy link
Contributor

franpb14 commented May 30, 2022

The same applies to the data(query, attribute, 0) method. I think changing this line to if(value == null) would work correctly.

@markets
Copy link
Member

markets commented Jun 1, 2022

We'll introduce a couple of new methods for now (see #54) to be able to remove attributes and data-*, but for the sake of reference, we also discussed the following ideas:

@markets
Copy link
Member

markets commented Jun 2, 2022

#54 has been merged 🎉

@jfelip937 @franpb14 feel free to close this one or keep it open to analyze/discuss new APIs and possibilities

@markets markets added discussion and removed enhancement New feature or request labels Jun 2, 2022
@markets markets closed this as completed Aug 26, 2022
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

3 participants