From 2597de64bec4c53efa91f1e536866fdf476ed196 Mon Sep 17 00:00:00 2001 From: Huazhou Wang Date: Wed, 13 Oct 2010 19:39:35 +0800 Subject: [PATCH] Fix bad action in strict mode jQueryObject.attr("disable", false) does not remove but adds an attribute 'disable' with value 'false' from/to the target in XHTML strict mode, this makes all stylesheets disabled. View issue details at: http://github.com/plause/chrome-page-style/issues#issue/2 --- js/contentscript.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/js/contentscript.js b/js/contentscript.js index eb304b2..70cbaf1 100644 --- a/js/contentscript.js +++ b/js/contentscript.js @@ -22,17 +22,22 @@ return isStylesheet(link) && $(link).attr("title"); } + function toggleSheet(sheet, toggle) { + sheet.disabled = toggle; + sheet.disabled = toggle; + } + function toggleLinkedStyles(toggle) { $("link").each(function () { if (isStylesheet(this)) { - $(this).attr("disabled", true).attr("disabled", true); + toggleSheet(this, true); } }); } function toggleEmbeddedStyles(toggle) { $("style").each(function () { - $(this.sheet).attr("disabled", toggle).attr("disabled", toggle); + toggleSheet(this.sheet, toggle); }); } @@ -69,11 +74,11 @@ var val = name ? $(this).attr("title") != name : isAlternate(this); if (isStylesheet(this)) { - $(this).attr("disabled", val).attr("disabled", val); + toggleSheet(this, val); } }).each(function () { if (isPersistentStylesheet(this)) { - $(this).attr("disabled", false).attr("disabled", false); + toggleSheet(this, false); } });