Skip to content

@barneycarroll /fizzleSizzle.js
Last active

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Get rid of Sizzle's IE custom attributes
/*
In IE, Sizzle has to create custom attributes to be able to travel the DOM intelligently. The custom attributes are lengthy and nasty, and can often screw up your code if you rely on parsing markup. fizzleSizzle wipes all that stuff out.
*/
// Pass in a string of markup and get it back without Sizzle's shizzle
var fizzleShizzle = function(x){
return x.replace(/(nodeIndex|sizcache|sizset)[\w\d]*(="[^"]*")*/gi,'');
};
(function($){
if(!$) return;
// Strip the shizzle from the DOM; pass a truthy argument to do the same for all children
$.fn.fizzleShizzle = function(deep){
var $el = deep ? this.add(this.find('*')) || this;
// Iterate through the selection
$el.each(function(){
var
el = this,
ats = el.attributes;
// Iterate through attributes
$.each(ats,function(i,x){
// Is it one of these?
if(/^nodeIndex|^sizcache|^sizset/.test(x))
// Fizzle it
el.removeAttribute(x);
});
});
return this;
};
}(jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.