Skip to main content

Bug Tracker

Side navigation

#7654 closed bug (wontfix)

Opened November 29, 2010 07:43PM UTC

Closed November 29, 2010 08:31PM UTC

Last modified March 23, 2011 07:01PM UTC

cleaning warnings in jQuery

Reported by: arimbourg@ariworld.eu Owned by:
Priority: undecided Milestone: 1.6
Component: unfiled Version: 1.4.4
Keywords: Cc:
Blocked by: Blocking:
Description

I've cleaned the jQuery core code to avoid the warnings that appears in firefox error console (like "function X don't always return a value" or other "undefined properties").

You can access these copies here : http://hq.ariworld.eu/javascript/jquery-1.4.4-clean.js (and http://hq.ariworld.eu/javascript/jquery-1.4.2-clean.js )

There is one warning remaining : "Unexpected token in attribute selector: < ! >."

from line 4139 (4159 in my cleaned copy)

There may be some more warnings but I noticed only those appearing in my scripts.

I hope next versions could be fully clean...

Attachments (0)
Change History (12)

Changed November 29, 2010 08:31PM UTC by snover comment:1

resolution: → wontfix
status: newclosed

Thanks for the report, but this is not a jQuery bug. Warnings are NOT DANGEROUS and should be ignored. If you can’t deal with ignoring them yourself, please change your error console’s settings so that it only shows errors. We won’t bloat the library to remove superfluous CSS warnings.

Changed November 29, 2010 09:48PM UTC by arimbourg@ariworld.eu comment:2

I know I can disable warnings and that they are not dangerous... but I always prefer writing scripts that don't produce any warnings rather than disabling these warnings. It's always better. Now if you don't want these corrections, do as you want... It's not difficult to avoid them... it only take some time to clean your file for each new release...

Changed November 30, 2010 01:44AM UTC by rwaldron comment:3

I'm just curious... what are we expected to do with those links above? Have you ever looked at the jQuery source code on github.com?

https://github.com/jquery/jquery

A cursory review of your code reveals nothing to me about what you've cleaned... and I did a control+f for "clean" and found no comments left by you.

Changed November 30, 2010 03:22AM UTC by ajpiano comment:4

http://paste.pocoo.org/compare/297742/297741/

his change makes two minor tweaks in property detection for jquery on window, and adds "return null" 40 times.

jQuery passes JSLint, it does not need to pass the... "Don't have any Firebug Warnings" test, especially if it just means adding return null to functions that don't need to return anything.

Changed November 30, 2010 05:31PM UTC by arimbourg@ariworld.eu comment:5

To ajpiano

I cleaned jQuery to avoid the strict warnings appearing in firefox error console (not firebug).

I added "return null" (or sometimes just "null" to existing "return") to avoid "function don't always return a value" warnings. The functions where I added that returned a value yet in a condition or loop. So don't say that I added "return null to function that don't need ...".

A "return;" or a "return null;" or a function without "return;" returns the same value (or that could be "undefined"). I used "null" because I saw that you commonly use it in conditions. It don't change anything to the behavior of jQuery... but it's cleaner (... good practice).

I also visited JSLint. The validator is stricter than me and display more warnings than me. (I didn't find the "Don't have any Firebug Warnings" option).

To rwaldron,

I just offered to check them and maybe to include these 'cleanings' for the next versions. If you want, I can check the src files form github and clean them and add comments too...

If you don't want my help, I'll just continue cleaning my copies each time a new version comes...

Changed November 30, 2010 05:48PM UTC by rwaldron comment:6

The changes you've made are across both jQuery and Sizzle. Also, have you run these against the jQuery test suite?

Changed November 30, 2010 06:16PM UTC by ajpiano comment:7

_comment0: The "Don't have any Firebug Warnings" test was a made up, figurative test that describes the arbitrary goal of having jQuery not produce any Warnings from the Firefox console. It is not a real option for JSLint, which is the tool that jQuery uses for checking code for integrity and style. \ \ This is not a matter of "not wanting your help," which, if offerred for a different issue, we would gladly accept. It is simply that the "reward" of jQuery not producing warnings in the Firefox console (warnings which are not DANGEROUS is not worth the bulk of adding these changes to jQuery and Sizzle, which may behave unpredictably as they have not been run against the tests. \ \ Thank you for your time and interest in helping the jQuery project!1291141046374547

The "Don't have any Firebug Warnings" test was a made up, figurative test that describes the arbitrary goal of having jQuery not produce any Warnings from the Firefox console. It is not a real option for JSLint, which is the tool that jQuery uses for checking code for integrity and style.

This is not a matter of "not wanting your help," which, if offerred for a different issue, we would gladly accept. It is simply that the "reward" of jQuery not producing warnings in the Firefox console is not worth the bulk of adding these changes to jQuery and Sizzle, which may behave unpredictably as they have not been run against the tests.

Thank you for your time and interest in helping the jQuery project!

Changed November 30, 2010 11:05PM UTC by arimbourg@ariworld.eu comment:8

To rwaldron

I didn't use the jQuery test suite (I didn't even know there's one). Are you talking about "http://jsfiddle.net/" ? I only used my test suite... a remake of window.alert function to test and check results... Just tell me where to find that tool and I'll try it.

To ajpiano

I would be happy to help for the more serious issues. Yesterday, I read some of them. What's the procedure?

Now, I've added comments to the modifications that I made in jQuery ( http://hq.ariworld.eu/javascript/jquery-1.4.4-clean+comments.js ). Reading these comments, you'll understand that it couldn't be any bad issue. Give me the test suite to be sure... or don't if a clean code is really not interesting...

Changed November 30, 2010 11:42PM UTC by rwaldron comment:9

_comment0: The jQuery test suite is a collection of 3688 unit tests that jQuery must pass in the browsers I listed above before it can be deemed release worthy. \ \ The tests exist to aid in avoiding major unexpected regressions in the jQuery source (unless the regression is somehow intended ) from one release to another. Imagine, i make one small change - like... returning null when nothing was previously returned. No big deal right? Wrong. Javascript functions ALWAYS return something - if it is no specified then the default behaviour is to return `undefined`. So what happens when some other piece of internal jQuery code is testing a condition in which it expects `undefined` to the result of its evaluation... but now you're returning null. This is what happens: \ \ 16 Failed tests spanning across the data and css modules. Only 2782 tests were allowed to run because the entire suite dies when it gets to the custom JSON-P tests. \ \ So I removed that test block, which is only 2 tests and those count against the total. Now you're failing 18. \ \ This allowed the rest of the suit to run and finish with 68 failures, plus the removed two for a total of '''70 failures''' across the data, css, ajax, effects and dimensions modules. \ \ This test was run in both Chromium 9.0.595.0 and Firefox 4b7 - in both browsers I ran the unmodified test suite to ensure 100% passing. Tomorrow I will run it against the older versions of IE. \ \ \ \ \ \ \ \ \ \ \ 1291161625836108

The jQuery test suite is a collection of 3688 unit tests that jQuery must pass in the browsers I listed above before it can be deemed release worthy.

The tests exist to aid in avoiding major unexpected regressions in the jQuery source (unless the regression is somehow intended ) from one release to another. Imagine, i make one small change - like... returning null when nothing was previously returned. No big deal right? Wrong. Javascript functions ALWAYS return something - if it is not specified then the default behaviour is to return undefined. So what happens when some other piece of internal jQuery code is testing a condition in which it expects undefined to the result of its evaluation... but now you're returning null. This is what happens:

16 Failed tests spanning across the data and css modules. Only 2782 tests were allowed to run because the entire suite dies when it gets to the custom JSON-P tests.

So I removed that test block, which is only 2 tests and those count against the total. Now you're failing 18.

This allowed the rest of the suit to run and finish with 68 failures, plus the removed two for a total of 70 failures across the data, css, ajax, effects and dimensions modules.

This test was run in both Chromium 9.0.595.0 and Firefox 4b7 - in both browsers I ran the unmodified test suite to ensure 100% passing. Tomorrow I will run it against the older versions of IE.

Changed December 01, 2010 02:53AM UTC by anonymous comment:10

You are right... I wrote that before...

(function () { }) () === undefined

true

(function () { }) () === null

false

(function () { return; }) () === undefined

true

(function () { return; }) () === null

false

(function () { return null; }) () === null

false

(function () { return null; }) () === null

true

(function () { return; }) () === undefined

true

(function () { return; }) () === null

false

(function () { return undefined; }) () === null

false

(function () { return null; }) () === null

true

ok... So let's return undefined...

Changed December 01, 2010 03:12PM UTC by arimbourg@ariworld.eu comment:11

No... it's not enough... I test now qunit...

Changed March 23, 2011 07:01PM UTC by Bill comment:12

I think the jquery developers need to go through and clean this up. Return null or undefined, whatever it takes in each case to get it right. Seems like it's nothing more than lazy/messy coding, and I don't see any technical reason for not fixing this. Having unnecessary warnings is just bad practice, and not acceptable for many professional users.

Perhaps jquery should make it a standard to address things like this before releasing, just like testing.

Don't take me wrong - I love the product and appreciate all the great work the team has done. But please try to understand the perspective of developers who use this in their professional work and thus can't make excuses or ignore this stuff, as unimportant as it might seem.

Thanks for taking this into consideration, and hopefully the issue can be straightened out without too much trouble.