Skip to content
Permalink
Browse files

Land some additional tweaks related to running through JSLint.

  • Loading branch information
jeresig committed Mar 1, 2010
1 parent fc08d0e commit a4043cdcbfa1ca069265a7cbcaba269629789cc0
Showing with 10 additions and 11 deletions.
  1. +1 −1 src/ajax.js
  2. +6 −6 src/core.js
  3. +1 −1 src/event.js
  4. +1 −1 src/manipulation.js
  5. +1 −2 src/traversing.js
@@ -2,7 +2,7 @@ var jsc = now(),
rscript = /<script(.|\s)*?\/script>/gi,
rselectTextarea = /select|textarea/i,
rinput = /color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week/i,
jsre = /=\?(&|$)/,
jsre = /\=\?(&|$)/,
rquery = /\?/,
rts = /(\?|&)_=.*?(&|$)/,
rurl = /^(\w+:)?\/\/([^\/?#]+)/,
@@ -49,7 +49,7 @@ var jQuery = function( selector, context ) {

// Save a reference to some core methods
toString = Object.prototype.toString,
hasOwnProperty = Object.prototype.hasOwnProperty,
hasOwn = Object.prototype.hasOwnProperty,
push = Array.prototype.push,
slice = Array.prototype.slice,
indexOf = Array.prototype.indexOf;
@@ -450,9 +450,9 @@ jQuery.extend({
}

// Not own constructor property must be Object
if ( obj.constructor
&& !hasOwnProperty.call(obj, "constructor")
&& !hasOwnProperty.call(obj.constructor.prototype, "isPrototypeOf") ) {
if ( obj.constructor &&
!hasOwn.call(obj, "constructor") &&
!hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
return false;
}

@@ -462,7 +462,7 @@ jQuery.extend({
var key;
for ( key in obj ) {}

return key === undefined || hasOwnProperty.call( obj, key );
return key === undefined || hasOwn.call( obj, key );
},

isEmptyObject: function( obj ) {
@@ -803,5 +803,5 @@ function access( elems, key, value, exec, fn, pass ) {
}

function now() {
return (new Date).getTime();
return (new Date()).getTime();
}
@@ -187,7 +187,7 @@ jQuery.event = {
type = namespaces.shift();

namespace = new RegExp("(^|\\.)" +
jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)")
jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)");
}

eventType = events[ type ];
@@ -205,7 +205,7 @@ jQuery.fn.extend({

return jQuery.clean([html.replace(rinlinejQuery, "")
// Handle the case in IE 8 where action=/test/> self-closes a tag
.replace(/=([^="'>\s]+\/)>/g, '="$1">')
.replace(/\=([^="'>\s]+\/)>/g, '="$1">')
.replace(rleadingWhitespace, "")], ownerDocument)[0];
} else {
return this.cloneNode(true);
@@ -1,8 +1,7 @@
var runtil = /Until$/,
rparentsprev = /^(?:parents|prevUntil|prevAll)/,
// Note: This RegExp should be improved, or likely pulled from Sizzle
rmultiselector = /,/,
slice = Array.prototype.slice;
rmultiselector = /,/;

// Implement the identical functionality for filter and not
var winnow = function( elements, qualifier, keep ) {

9 comments on commit a4043cd

@padolsey

This comment has been minimized.

Copy link
Contributor

padolsey replied Mar 2, 2010

In reference to 806, what's wrong with +new Date()?

@jeresig

This comment has been minimized.

Copy link
Member Author

jeresig replied Mar 2, 2010

@james: Nothing in particular (in that it works) but I've balked against it in the past because it's particularly "magical" and not always obvious what it's doing to someone who may be reading the source - whereas (new Date()).getTime() is very explicit and very obvious as to what the result is.

@padolsey

This comment has been minimized.

Copy link
Contributor

padolsey replied Mar 2, 2010

Fair point. I'm surprised closure compiler doesn't switch new Date().getTime() for +new Date...

@jdalton

This comment has been minimized.

Copy link
Member

jdalton replied Mar 2, 2010

Nothing magical about it. ECMA 5th Ed. Page 169, Section 15.9.3.1 [[PrimitiveValue]] makes it pretty clear. (new Date).valueOf(); would also do :P

@jeresig

This comment has been minimized.

Copy link
Member Author

jeresig replied Mar 2, 2010

@jdalton: To someone that reads specifications for fun, of course there's "Nothing magical about it." - but it's undeniable that it's much more obtuse than just doing a straight (new Date()).getTime(); or (new Date()).valueOf();.

@jdalton

This comment has been minimized.

Copy link
Member

jdalton replied Mar 2, 2010

Hehe, I hear @kangax is getting a tramp stamp that reads "strict";

@jdalton

This comment has been minimized.

Copy link
Member

jdalton replied Mar 2, 2010

*erm "use strict";, humor fail :D

@cowboy

This comment has been minimized.

Copy link
Member

cowboy replied Mar 2, 2010

Why not use +new Date() and then include a comment. You know, one of those new-fangled thingamawhatsits often included in source code just like this that explains to the uneducated developer what that particular bit of magic does?

@yfeldblum

This comment has been minimized.

Copy link

yfeldblum replied Mar 2, 2010

Comments are verboten.

On a serious note, it's a popular idea that code should be clear - that if a piece of code needs comments to explain what it does, then that piece of code should be rewritten no longer to need comments.

Appropriate optimizations are exceptions to this rule, as are such things as high-level descriptions of algorithms and data structures, high-level descriptions of design and architecture, examples of how to invoke the code, key assumptions and contexts, etc.

Please sign in to comment.
You can’t perform that action at this time.