Skip to content

Commit

Permalink
cleanup so jslint doesn't bitch so much.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish committed Sep 12, 2010
1 parent a7e8342 commit 945c78f
Showing 1 changed file with 18 additions and 21 deletions.
39 changes: 18 additions & 21 deletions modernizr.js
Expand Up @@ -85,7 +85,7 @@ window.Modernizr = (function(window,doc,undefined){
'select':'input','change':'input',
'submit':'form','reset':'form',
'error':'img','load':'img','abort':'img'
}
};

function isEventSupported(eventName, element) {

Expand All @@ -106,7 +106,7 @@ window.Modernizr = (function(window,doc,undefined){

// if property was created, "remove it" (by setting value to `undefined`)
if (typeof element[eventName] != 'undefined') {
element[eventName] = void 0;
element[eventName] = undefined;

This comment has been minimized.

Copy link
@fearphage

fearphage Sep 13, 2010

Contributor

Why don't you delete the property instead?

This comment has been minimized.

Copy link
@paulirish

paulirish Sep 13, 2010

Author Member

is deleting properties from DOM elements totally kosher? :/

This comment has been minimized.

Copy link
@jdalton

jdalton Sep 13, 2010

Contributor

Naw using the delete operator isn't kosher and will throw errors in IE < 8.
Also it seems the delete operator and removeAttribute won't remove the event handler like setting it to null in browsers like Firefox. (though I could swear spec has something about removeAttribute being equiv to nulling the value.)

What Paul has is probably the best way to handle IE and others.

This comment has been minimized.

Copy link
@fearphage

fearphage Sep 13, 2010

Contributor

And this is me shutting up... At least I learned something new.

This comment has been minimized.

Copy link
@jdalton

jdalton Sep 13, 2010

Contributor

It's good to question things and experiment :D

}
element.removeAttribute(eventName);

This comment has been minimized.

Copy link
@jdalton

jdalton Sep 13, 2010

Contributor

^^ IE for great justice <3

}
Expand Down Expand Up @@ -335,13 +335,13 @@ window.Modernizr = (function(window,doc,undefined){
};

tests['draganddrop'] = function() {
return isEventSupported('drag')
&& isEventSupported('dragstart')
&& isEventSupported('dragenter')
&& isEventSupported('dragover')
&& isEventSupported('dragleave')
&& isEventSupported('dragend')
&& isEventSupported('drop');
return isEventSupported('drag') &&
isEventSupported('dragstart') &&
isEventSupported('dragenter') &&
isEventSupported('dragover') &&
isEventSupported('dragleave') &&
isEventSupported('dragend') &&
isEventSupported('drop');
};


Expand Down Expand Up @@ -517,17 +517,13 @@ window.Modernizr = (function(window,doc,undefined){
tests['fontface'] = function(){

var
sheet, style, result,
sheet,
head = doc.head || doc.getElementsByTagName('head')[0] || docElement,

impl = doc.implementation ||
{ hasFeature: function() { return false; } },

style = doc.createElement("style");
style = doc.createElement("style"),
impl = doc.implementation || { hasFeature: function() { return false; } };

style.type = 'text/css';

head.insertBefore(style, head.firstChild);

sheet = style.sheet || style.styleSheet;

// removing it crashes IE browsers
Expand All @@ -547,10 +543,11 @@ window.Modernizr = (function(window,doc,undefined){
function(rule) {
if (!(sheet && rule)) return false;
sheet.cssText = rule;
return sheet.cssText.length !== 0 &&
!(/unknown/i).test(sheet.cssText) &&
sheet.cssText.replace(/\r+|\n+/g, '').
indexOf(rule.split(' ')[0]) === 0;

return sheet.cssText.length !== 0 && !(/unknown/i).test(sheet.cssText) &&
sheet.cssText
.replace(/\r+|\n+/g, '')
.indexOf(rule.split(' ')[0]) === 0;
};


Expand Down

0 comments on commit 945c78f

Please sign in to comment.