Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 8259f10

Browse files
committed
fix(jqLite): make attr() compatible with jQuery 1.6.4
The behavior of attr() getter and setter changed in jQuery 1.6 and now they treat element properties and attributes as two different things, but in order to not break everyone there is a partial backwards compatibility for checking and updating element properties as well. see http://api.jquery.com/prop/ for more info.
1 parent ab407de commit 8259f10

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/jqLite.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,15 @@ forEach({
255255
attr: function(element, name, value){
256256
if (SPECIAL_ATTR[name]) {
257257
if (isDefined(value)) {
258-
element[name] = !!value;
258+
if (!!value) {
259+
element[name] = true;
260+
element.setAttribute(name, name);
261+
} else {
262+
element[name] = false;
263+
element.removeAttribute(name);
264+
}
259265
} else {
260-
return element[name];
266+
return (element[name] || element.getAttribute(name)) ? name : undefined;
261267
}
262268
} else if (isDefined(value)) {
263269
element.setAttribute(name, value);

0 commit comments

Comments
 (0)