Deprecation.js: easing the 1.5 → 1.6 transition

by Andrew | February 12th, 2008

If you’ve put off the task of upgrading your old code to Prototype 1.6, now you’re out of excuses. Core team member Tobie Langel has developed a script that will warn you of any deprecations or API changes.

The script is meant to be used with Firebug, so it’s Firefox-only — but when you’re done, your code will be ready for use alongside Prototype 1.6 in all browsers.

deprecation.js screenshot

Using the script is easy. To migrate a page from 1.5 to 1.6:

  1. Find the script tag that references prototype.js. Change the path to point to the 1.6.0.2 version (or else overwrite the existing prototype.js with the new version).
  2. On the very next line, add a script tag that references deprecation.js.
  3. Develop your app as normal.

When your code calls a method that’s been deprecated, replaced, or modified, the script will log a warning or error to your Firebug console. Clicking its hyperlink will take you to the deprecation script itself, which isn’t all that helpful; but the message itself will contain a stack trace that points to the source of the error.

Naturally, the console errors are the most important to address, since they represent things that will no longer work in 1.6. The warnings represent deprecations — things that still work in 1.6, but are not guarateed to work in future versions of Prototype. If you’d like to see only removal notices, you can set a property in your code to turn off deprecations:

DeprecationNotifier.logDeprecation = false;

As you address these errors and warnings, they’ll go away. When there are no more errors, your code is compatible with 1.6. When there are no more warnings, your code is nimble and future-proof.

Download the deprecation script.

Comments

  1. Mark Holton #

    ...this is really helpful and useful, many thanks Tobie, appreciate it.

    February 12th, 2008 @ 03:24 PM
  2. TweeZz #

    Very nice. I’m jealous when I see how you guys can write javascript code! So much to learn!

    February 13th, 2008 @ 12:52 AM
  3. Tobie Langel #

    Note that I’d be interested in exploring the possibility of turning this into a Firebug extension.

    If there’s anyone that would be interested in helping out with this, please step up!

    February 13th, 2008 @ 03:33 AM
  4. JFR #

    Hi,

    Do you have a sample page to test ?

    I would like to check if the console feature is also working with Companion.JS that emulates “console.log” feature to IE (shoud be, but just to be sure).

    Thanks.

    February 13th, 2008 @ 08:09 AM
  5. Tobie Langel #

    @JFR: Unfortunately, the deprecation is Firefox only, not because it relies on Firebug… but because it’s using some advanced features of JavaScript, not yet implemented in IE.

    February 13th, 2008 @ 08:25 AM
  6. JFR #

    Well, that’s bad :-(

    Thanks for your answer.

    JFR

    February 13th, 2008 @ 09:13 AM
  7. Morten #

    Then you should have not probs upgrading prototypejs.org from 1.5 to 1.6 :-)

    February 15th, 2008 @ 05:34 AM
  8. Tobie Langel #

    @Morten: Yeah, we’re just a busy bunch ;)

    February 15th, 2008 @ 05:38 AM
  9. sftco #

    Thats cool any code that allows simple upgrade is always best.

    February 19th, 2008 @ 08:14 AM
  10. np #

    Very nice. This is an awesome tool for upgrade that few open source library maintainers would actually take the time to bring up, Thanks Tobie !

    February 20th, 2008 @ 08:46 AM
  11. randy #

    Does this work with 1.4 to 1.6 migration as well? I inherited 1.4 and could not update before due to depency on old rico.js 1.1.3.

    I looked at 1.5 documentation/release notes on possible migration help from 1.4 to 1.5; did not have much luck.

    Now planning to update to latest version of prototype 1.6.02…any ideas/tips is greatly appreciated!!

    February 20th, 2008 @ 01:27 PM
  12. Tobie Langel #

    @Randy: This should work to upgrade from 1.4 to 1.6 too. Please let us know how it goes.

    February 20th, 2008 @ 01:34 PM
  13. Randy #

    Upgrade to 1.6 easilty and is working fine with FF2.0.

    Having issues with IE 7 (specifically with Ajax updater). Any known issues/tips to deal with IE7?

    February 26th, 2008 @ 04:52 AM
  14. Tobie Langel #

    Thanks for the update Randy!

    Glad to know this helped you migrate from 1.4 to 1.6.

    Regarding your specific issues, I think they’re best asked on the mailing list.

    February 26th, 2008 @ 07:07 AM
  15. fearphage #

    @Tobie Langel: Opera supports getters and setters and it’s equivalent to console.log is opera.postError. Why isn’t Opera supported?

    February 28th, 2008 @ 09:31 AM
  16. fearphage #

    Correction: Opera and Safari support getters and setters. Safari supports console.log however I’m not sure if the debug menu has to be enabled for this to function. Opera’s equivalent is opera.postError. The only thing unable to be supported should be IE.

    February 28th, 2008 @ 09:45 AM
  17. Tobie Langel #

    @fearphage: I’m aware of that (except Safari 2 doesn’t support getters and setters). I wanted to get this out as soon as possible, and suspect the amount of developers using Opera/Safari as their main developing browser is pretty small. You’re more than welcome to post a patch though.

    February 28th, 2008 @ 10:48 AM
  18. Jason #

    Really cool! Easy to use. :)

    February 29th, 2008 @ 01:32 PM
  19. DS_tm #

    Sorry for question, but WHEN your API Documentation for prototype 1.6.0.2 will be done?

    P.S. Great thanks for you work from Russia!)

    March 3rd, 2008 @ 10:51 AM
  20. Tobie Langel #

    @DS_tm: We’re currently busy writing a custom solution to embed the documentation as inline comments in the source code. You should hear more about this soon, so stay tuned.

    March 3rd, 2008 @ 12:21 PM
  21. DS_tm #

    @Tobie Langel: Oh, it’s a excellent idea! Good luck in your job guys.

    March 4th, 2008 @ 02:48 AM

Sorry, comments are closed for this article.

Search Blog


Search the prototype blog.

Subscribe to the blog

Akismet badge