zepto icon indicating copy to clipboard operation
zepto copied to clipboard

$.attr() handles boolean properties wrongly

Open PhilippMi opened this issue 7 years ago • 3 comments

$el.attr({checked: true}) results in the following html <input checked="true"> which is not allowed in HTML5.

jquery handles this case correctly. jquery: https://codepen.io/phmitterer/pen/QvBXgE?editors=1111 zepto: https://codepen.io/phmitterer/pen/KmBjmN?editors=1111

PhilippMi avatar May 17 '17 07:05 PhilippMi

use the prop()

hkongm avatar May 27 '17 01:05 hkongm

It would probably be good to handle this the same way as jQuery does.

madrobby avatar Aug 06 '17 12:08 madrobby

I'm working on a PR for this issue. But instead of doing it like jQuery, which results in <input checked="checked">, I think it ought to be <input checked>. The first form is "non-standard" according to MDN. This wouldn't break compatibility as long as we return the correct value from $('input').attr('checked'). Thoughts?

chris-oreilly avatar Aug 07 '17 19:08 chris-oreilly