-
Notifications
You must be signed in to change notification settings - Fork 20.6k
Return null from .attr when attributes don't exist #2118
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
Comments
@dmethvin We're leaning towards doing this for beta. Do you know of a use case that would make this catastrophic? |
It seems like returning |
Thanks; that reminded me to create #2134. |
Of course the answer turns out to be jQuery UI :-) I'm working on updates right now. |
The team decided to revert this due to breakages in UI and mobile. |
We backed this out for 1.12/2.2 which definitely seems right, but it's also excluded from 3.0. Should it be? That is, do we want a non-existent attribute to return |
I removed the milestone due to the revert and opened the issue & added the "Needs review" label to account for the Dave's question. |
I remember this discussion, we reverted cause it might be dangerous to do which proved the UI breakage, where is literally no gain from, except to align with standard, whereas behaviour in DOM spec is very questionable in the first place, since in all others JS API you get |
.attr("nonexistent")
currently returnsundefined
, probably from the days before.prop
. But the native DOMgetAttribute
andSizzle.attr
both returnnull
in such cases. Also,.attr( name, null )
removes attributes, and it would be very convenient to allow universal round-tripping.Let's consider changing the return value to accommodate.
Note that setter treatment of
undefined
is explicitly out-of-scope for this ticket, as are.prop
and.data
round-tripping, although those are certainly related topics.The text was updated successfully, but these errors were encountered: