Noexpando plugin

Noexpando plugin


Hi,
i wrote a small plugin that can disable and restore expandos. It can be
used in cases where Internet Explorer has problems with expandos, for
example if you attached data to nodes and .html() them (a small demo can
be found at http://vmx.cx/tmp/jquery/noexpando/demo.htm). This isn't the
only case, probably more important are the designMode issues (search the
archive for more information).
The only problem is that the plugin will only work with a patched
jQuery. The patch is only 1 line long. It would be great if the patch
could go into trunk.
-Volker.
Patch:
--- jquery-1.2.js    2007-09-11 00:04:14.000000000 +0200
+++ jquery-1.2_exando.js    2007-09-14 14:53:02.000000000 +0200
@@ -542,6 +542,8 @@
        }
    },
+    expando: expando,
+
    // args is for internal usage only
    each: function( obj, fn, args ) {
        if ( args ) {
Plugin:
(function($) {
$.fn.disableExpando = function() {
var jqObj = this;
jqObj.uuids = new Array();
var expando = $.expando;
this.each(function() {
// Save Uuids to be able to restore them later
jqObj.uuids.push([this, $.data(this)]);
// NOTE from jQuery 1.2
// Clean up the element expando
try {
delete this[ expando ];
} catch(e){
// IE has trouble directly removing the expando
// but it's ok with using removeAttribute
if ( this.removeAttribute )
this.removeAttribute( expando );
}
});
return this;
};
$.fn.enableExpando = function() {
var uuids = this.uuids;
var expando = $.expando;
var cnt = 0;
this.each(function() {
if (uuids[cnt][0] == this) {
this[ expando ] = uuids[cnt][1];
cnt++;
}
});
return this;
};
})(jQuery);

























































    • Topic Participants

    • vmx