ralixjs / ralix

✨ Microframework for building and organizing your front-end

Home Page:https://www.npmjs.com/package/ralix

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow attr() helper method to receive false as value

jfelip937 opened this issue · comments

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).

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

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:

#54 has been merged 🎉

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