$.fn.href() example breaks in jQuery 1.7.2
Closed this issue · 2 comments
We had a long-standing bug regarding our treatment of undefined
that we fixed in 1.7.2 by using arguments.length
to determine whether a method is being called as a setter or getter:
http://bugs.jquery.com/ticket/5571
Here's a test case and one possible solution:
http://jsfiddle.net/dmethvin/2x4QR/
I'm treating this more like a duck punch with that solution, where as a general hygiene issue it's always best to pass along any args so that future enhancements are less likely to break. For training other people it is probably better to just use an if and call .prop()
differently for the getter/setter case.
I'm not sure what I should do here. There was a backwards-breaking method signature change in a patch release, which is bad. But apart from that, something that has always been a very simple thing to implement is now significantly more complex. I completely understand the reasoning behind the change, but might there be a nicer solution?
I added a comment to http://bugs.jquery.com/ticket/5571 with my observations.
FWIW, I'm trying to edit my preso, and this totally kills the narrative. I'm not sure how to handle it.