From 8259f101389afc1b5b1f044b2b07bf6f8f44fc83 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Thu, 15 Sep 2011 21:11:45 +0200 Subject: [PATCH] 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. --- src/jqLite.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/jqLite.js b/src/jqLite.js index af488abbe220..67b6137d4aed 100644 --- a/src/jqLite.js +++ b/src/jqLite.js @@ -255,9 +255,15 @@ forEach({ attr: function(element, name, value){ if (SPECIAL_ATTR[name]) { if (isDefined(value)) { - element[name] = !!value; + if (!!value) { + element[name] = true; + element.setAttribute(name, name); + } else { + element[name] = false; + element.removeAttribute(name); + } } else { - return element[name]; + return (element[name] || element.getAttribute(name)) ? name : undefined; } } else if (isDefined(value)) { element.setAttribute(name, value);