Prototype Changes

I found this article via Ajaxian regarding a nice block of Prototype updates.

  • Shorter syntax for event handling
    JAVASCRIPT:
    1. $('element').observe('click', function(e) {  alert(e); });

  • Make destructive Element, Form, and Form.Element methods return their first argument, so that multiple calls can be chained together.
    JAVASCRIPT:
    1. $(“sidebar”).addClassName(“selected”).show();

    The following methods now return their first argument: Element.toggle, Element.hide, Element.show, Element.remove, Element.update, Element.replace, Element.addClassName, Element.removeClassName, Element.observe, Element.stopObserving, Element.cleanWhitespace, Element.scrollTo, Element.setStyle, Element.makePositioned, Element.undoPositioned, Element.makeClipping, Element.undoClipping, Form.reset, Form.disable, Form.enable, Form.focusFirstElement, Form.Element.focus, Form.Element.select, Form.Element.clear, Form.Element.activate, Form.Element.disable, Form.Element.enable.

  • Form and Form.Element methods mixed in to $ and $$
  • For consistency, Element.toggle, Element.show, and Element.hide no longer take an arbitrary number of arguments.

    !! BACKWARDS COMPATIBILITY CHANGE !!

    If you have code that looks like this: Element.show(‘page’, ‘sidebar’, ‘content’); You need to replace it with code like this: [‘page’, ‘sidebar’, ‘content’].each(Element.show);

  • Mix in Form and Form.Element methods to forms and form field elements with $() and $$(). Closes #4448. [Dan Webb, sam]
  • Add Object.clone
  • Add Form.Element.disable and Form.Element.enable. Closes #4943.
  • Field is now simply an alias for Form.Element.
  • Add Element.Methods.getElementsByClassName and Element.Methods.getElementsBySelector. Closes #4669.
  • Avoid race condition when stopping an Ajax.PeriodicalUpdater. Closes #4809.
  • Improve support for synchronous requests. Closes #5916.
  • Add serialization and observation support for input type=search. Closes #4096.
  • Properly decode query components in String.prototype.toQueryParams. Closes #3487.
  • Add Array.prototype.reduce:
    • [1, 2].reduce() // [1, 2]
    • [1].reduce() // 1]
    • [].reduce() // undefined]
  • Add Object.keys and Object.values
  • Simulate non-GET/POST requests by POSTing with a _method parameter set to the actual verb
  • Make Element.update() handle TABLE-related elements with the DOM API because of IE’s missing .innerHTML property on them
  • Sync to script.aculo.us unittest.js library as of 2006/08/29
  • Add additional unit tests to test/unit/dom.html for testing Element.update and $().update in various enviroments
  • Prevent possible exceptions on unloading the page in IE

I'm psyched!

Discuss This Article


3 Responses to “Prototype Changes”

  1. Avatarsp

    Oh, by the way, is there any “prototype official blog” or something, where any kinds of announcements can be found? It seems very strange to me, that such a wide-used library like prototype is so poorly documented and (btw) hadn`t been updated for such a long period of time.

    Reply to this comment.
    1
  2. Avatarasd
    2
  3. AvatarYeago

    Worst colorscheme on the internet.

    Dark gray on black? Are you drunk?

    Lots of good info here, to those who don’t mind the squint.

    Reply to this comment.
    3

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Comment Preview:

 (4840) - prototype disable link (29) - prototype checkbox (24) - prototype hide (23) - prototype toggle (14) - prototype show hide (14) - prototype selectedIndex (14) - prototype simulate click (13) - prototype observe checkbox (13) - toggle prototype (12) - prototype scrollto (12) - prototype disable field (9) - prototype hide show (9) - prototype disable button (9) - prototype get innerHTML (9) - prototype add element (8) - prototype changelog (8) - prototype update field (8) - prototype disable href (8) - prototype disable (7) - element (7) - javascript prototype selectedindex (7) - prototype disable select (7) - element.prototype IE (6) - prototype disable form element (6) - prototype add form element (6) - prototype select multiple (6) - prototype disabled (5) - prototype update select (5) - prototype add element to form (5) - prototype remove select (5) - prototype hide() (5) - prototype toggle example (5) - disable link prototype (5) - prototype toggle innerhtml (5) - prototype multiple elements (5) - prototype select multiple elements (5) - prototype select selected (5) - prototype observe select change (5) - prototype update form (4) - prototype disable fields (4) - prototype add form fields (4) - prototype select disable (4) - simulate click prototype (4) - disable checkbox prototype (4) - prototype add select (4) - prototype add field to form (4) - IE javascript Element.prototype (4) - prototype remove focus (4) - prototype multiple select (4) - prototype toqueryparams (3) - javascript prototype replace() (3) - innerHTML prototype (3) - prototype form add element (3) - javascript prototype disable field (3) - prototype update ie (3) - prototype add form field (3) - disable field prototype (3) - show hide prototype (3) - internet explorer Element.prototype (3) - toggle prototype example (3) - prototype add elements (3) - javascript prototype add element (3) - prototype add field (3) - prototype show hide form (3) - prototype checkbox disabled (3) - prototype set innerhtml (3) - prototype select (3) - internet explorer javascript Element.prototype (3) - prototype effect scrollto (3) - prototype.js disable link (3) - prototype select add (3) - prototype javascript simulate click (3) - checkbox prototype (3) - prototype remove link (3) - prototype disable element (2) - prototype replace element (2) - prototype disable form (2) - scrollto element (2) - prototype disable form field (2) - prototype forms (2) - prototype form disable (2) - prototype show (2) - prototype form element enable (2) - prototype toggle multiple divs (2) - prototype disable a link (2) - prototype form hide (2) - prototype hide multiple elements (2) - prototype Element.stopObserving (2) - prototype toggle element (2) - IE element.prototype (2) - prototype toggle enable (2) - prototype observe multiple elements (2) - prototype update form fields (2) - javascript prototype web form help text toggle (2) - prototype add form (2) - prototype disable text field (2) - update field prototype (2) - prototype disable example (2) - javascript table show block prototype (2) - prototype toggle sample (2) - prototype select disabled (2) - prototype add element to select (2) - prototype checkbox disable.. (2) - disable field javascript (2) - prototype form.reset not resetting (2) - prototype clear checkbox (2) - prototype checkbox observe (2) - prototype disable table (2) - prototype checkbox select (2) - element.toggle element.update (2) - toogle with prototype (2) - prototype hiding multiple (2) - protoype toggle appear (2) - prototype disable a href (2) - prototype add to select (2) - prototype checkbox clear (2) - prototype.js enable disable button (2) - Prototype setstyle IE7 (2) - toggle show hide prototype (2) - prototype Effect.ScrollTo (2) - javascript element.prototype ie (2) - prototype select remove (2) - prototype form change (2) - form select prototype (2) - prototype disabled form javascript (2) - prototype how to select selected (2) - prototype js add element (2) - replace entire form prototype javascript (2) - prototype Form add (2) - Element.prototype javascript ie (2) - prototype add element to page (2) - prototype element show function internet explorer issues (2) - prototype link disable (2) - prototype.js observe checkbox (2) - prototype get Element select (2) - prototype select change (2) - prototype.js add Element methods (2) - prototype observing multiple elements (2) - prototype js form show hide samples (2) - prototype select innerHTML (2) - prototype checkbox enable (2) - prototype three state checkbox (2) - prototype toggle cancelBubble (2) - multiple hide show enable disable forms (2) - javascript element setStyle ie7 (2) - prototype field.disable (2) - prototype show selected (2) - prototype (1) - javascript element.prototype (1) -