Notices in unamended prototype.js version 1.5.0_rc1

10 views
Skip to first unread message

RQuadling

unread,
Jan 19, 2007, 7:35:47 AM1/19/07
to Prototype: Core
Hi.

Using FF with FireBug, and loading the library all by itself, there are
25 "info" entries in the FireBug Console.

The list as it stands is ...

variable object hides argument
var __method = this, args = $A(arguments), object = args.shift();\n
prototype.js (line 76)

test for equality (==) mistyped as assignment (=)?
if (match = source.match(pattern)) {\n
prototype.js (line 158)

test for equality (==) mistyped as assignment (=)?
if (result = !!(iterator || Prototype.K)(value, index))\n
prototype.js (line 358)

anonymous function does not always return a value
},\n
prototype.js (line 975)

test for equality (==) mistyped as assignment (=)?
if (receiver = $(receiver)) {\n
prototype.js (line 1010)

test for equality (==) mistyped as assignment (=)?
while (element = element[property])\n
prototype.js (line 1204)

anonymous function does not always return a value
if (elementClassName.length == 0) return false;\n
prototype.js (line 1296)

anonymous function does not always return a value
return true;\n
prototype.js (line 1299)

anonymous function does not always return a value
return false;\n
prototype.js (line 1300)

anonymous function does not always return a value
return element;\n
prototype.js (line 1306)

anonymous function does not always return a value
return element;\n
prototype.js (line 1312)

anonymous function does not always return a value
return element;\n
prototype.js (line 1318)

test for equality (==) mistyped as assignment (=)?
while (element = element.parentNode)\n
prototype.js (line 1350)

test for equality (==) mistyped as assignment (=)?
if(value = (element.getStyle('filter') ||
'').match(/alpha\(opacity=(.*)\)...
prototype.js (line 1384)

test for equality (==) mistyped as assignment (=)?
while (match =
expr.match(/^(.*)\[([a-z0-9_:-]+?)(?:([~\|!]?=)(?:"([^"]*)"|(...
prototype.js (line 1759)

test for equality (==) mistyped as assignment (=)?
while (match = expr.match(/^([^a-z0-9_-])?([a-z0-9_-]+)(.*)/i)) {\n
prototype.js (line 1767)

anonymous function does not always return a value
},\n
prototype.js (line 1780)

test for equality (==) mistyped as assignment (=)?
if (clause = params.id)\n
prototype.js (line 1787)

test for equality (==) mistyped as assignment (=)?
if (clause = params.tagName)\n
prototype.js (line 1789)

test for equality (==) mistyped as assignment (=)?
if (clause = params.attributes) {\n
prototype.js (line 1794)

test for equality (==) mistyped as assignment (=)?
if (element = $(this.params.id))\n
prototype.js (line 1827)

anonymous function does not always return a value
},\n
prototype.js (line 2392)

test for equality (==) mistyped as assignment (=)?
} while (element = element.offsetParent);\n
prototype.js (line 2406)

test for equality (==) mistyped as assignment (=)?
} while (element = element.parentNode);\n
prototype.js (line 2414)

assignment to undeclared variable ObjectRange
ObjectRange = Class.create();
prototype.js (line 723)

None of these are life threatening, but they can be removed by a little
spring cleaning.

When debugging, not having the warnings helps see the real problems.

I've only just started looking into prototype.js.

I've just started using scriptaluous too.

Thank you.

Richard Quadling.

Mislav Marohnić

unread,
Jan 19, 2007, 7:58:38 AM1/19/07
to prototy...@googlegroups.com
These aren't warnings, these are notices and they can be turned off (they are off by default). I suggest you do that to properly debug real warnings and errors.

We already had requests for keeping the lib "compatible" with jslint, but the current core developers didn't express any concern about these notices. Prototype framework perfectly valid JavaScript and these notices are intended for under-experienced programmers anyway. If we want to have assignment in a condition, we know what we are doing, and we certainly don't want to be warned about it.

Strict JavaScript is an option which we didn't opt for.

-M

Mislav Marohnić

unread,
Jan 19, 2007, 8:00:16 AM1/19/07
to prototy...@googlegroups.com
Sorry, read the ill-formed sentence above as "Prototype framework is coded in perfectly valid JavaScript..."

-M

Richard Quadling

unread,
Jan 20, 2007, 3:56:07 AM1/20/07
to prototy...@googlegroups.com
Would a patch to remove the notices be acceptable to the developers?
As a developer of commercial software for nearly 20 years and only
recently coming to web development, I am still learning about what
different rules apply. One of the things I've always thought is that
if my code produces any sort of warnings now, there is always the
chance that in years to come those warnings could become errors. If
the compiler/interpreter is producing a warning, then I should code it
to remove the possibility of ambiguity. Whilst the code works fine,
removing these notices can only be a good thing.

I don't want to turn off the notices as my own code sometimes has them
and I go "Doh! Duh!" and fit it. It would remove the noise and help
other developers who may not be as efficiently experienced and who do
make the sort of mistakes that these notices are highlighting.

Richard.


--
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"

Thomas Fuchs

unread,
Jan 20, 2007, 4:49:43 AM1/20/07
to prototy...@googlegroups.com
Ahm, no.

As there is no compiler involved, these "warnings" are generated by
the JavaScript interpreter, and are purely meant for catching typos
and other things. They are more annoying than helpful if you know
what you're doing.

Mind you, these warnings are purely out of the imagination of the
developers of one particular browser, and if you get rid of these
warnings, suddenly other warnings could pop up in the next browser
version...

Here's an article about it:
http://www.howtocreate.co.uk/strictJSFirefox.html

We have perfectly valid JavaScript, so no need for a patch. Also, if
something breaks in JavaScript in 5 years it will take half the
internet down with it, so no need to have headaches over that... :)

Best,
Thomas

Richard Quadling

unread,
Jan 22, 2007, 3:54:44 AM1/22/07
to prototy...@googlegroups.com
Aha! Thank you very much for the pointers on this. I apologise for
creating the noise. I would suggest adding something to the main
website about this as I am sure you get a lot of queries from
non-beginner, but non-advanced, developers (people like me).

An excellent product and extremely useful for me.

Thank you again.

Richard Quadling.

Reply all
Reply to author
Forward
0 new messages