Skip to content

Commit

Permalink
unbreaking the script (woops)
Browse files Browse the repository at this point in the history
  • Loading branch information
fearphage authored and paulirish committed Dec 8, 2009
1 parent 0d2058d commit ff02168
Showing 1 changed file with 32 additions and 21 deletions.
53 changes: 32 additions & 21 deletions modernizr.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,35 +140,46 @@ window.Modernizr = (function(window,doc){
i,
feature,
classes = [],
cache;

/**
* isEventSupported determines if a given element supports the given event
* function from http://yura.thinkweb2.com/isEventSupported/
*/
function isEventSupported(eventName, element) {
var canCache = (arguments.length == 1);

// only return cached result when no element is given
if (canCache && cache[eventName]) {
return cache[eventName];
}

element = element || document.createElement(TAGNAMES[eventName] || 'div');
eventName = 'on' + eventName;

// When using `setAttribute`, IE skips "unload", WebKit skips "unload" and "resize"
// `in` "catches" those
var isSupported = (eventName in element);
isEventSupported = (function(){

var TAGNAMES = {
'select':'input','change':'input',
'submit':'form','reset':'form',
'error':'img','load':'img','abort':'img'
},
cache = { };

if (!isSupported && element.setAttribute) {
element.setAttribute(eventName, 'return;');
isSupported = typeof element[eventName] == 'function';
function isEventSupported(eventName, element) {
var canCache = (arguments.length == 1);

// only return cached result when no element is given
if (canCache && cache[eventName]) {
return cache[eventName];
}

element = element || document.createElement(TAGNAMES[eventName] || 'div');
eventName = 'on' + eventName;

// When using `setAttribute`, IE skips "unload", WebKit skips "unload" and "resize"
// `in` "catches" those
var isSupported = (eventName in element);

if (!isSupported && element.setAttribute) {
element.setAttribute(eventName, 'return;');
isSupported = typeof element[eventName] == 'function';
}

element = null;
return canCache ? (cache[eventName] = isSupported) : isSupported;
}

element = null;
return canCache ? (cache[eventName] = isSupported) : isSupported;
}
return isEventSupported;
})();

/**
* set_css applies given styles to the Modernizr DOM node.
Expand Down

0 comments on commit ff02168

Please sign in to comment.