Prototype 1.7

Alex R. Young





frameworks prototype

Prototype 1.7

Posted by Alex R. Young on .

frameworks prototype

Prototype 1.7

Posted by Alex R. Young on .

Prototype 1.7 RC1
has been released, which introduces Sizzle for
the selector engine, Element#on,
Element.Layout, and bug fixes.


Sizzle has been on the cards for a long time, but it's actually becoming
a reality. Building Prototype with different selector engines is
possible, including the original, by using Rake:

rake dist SELECTOR_ENGINE=legacy_selector


This is a shortcut for binding events:

$("messages").on('click', 'a.class_name', function(event, element) {
  // Your event code here

This removes a line of code from Prototype 1.6 style code where elements
are extracted from the event.


Prototype now has a consolidated measurement API:

$('elementID').measure('width'); // Integer


ES5 compliance forms a big part of the bug fixes. There are also
performance optimisations. The release is tagged as 1.7rc1 on GitHub,
with a summary of all the changes in the

My Take

These changes are positive -- Element#on makes Prototype
code more concise, and measuring elements has always been slightly
clumsy so the new layout API might have positive repercussions,
particularly for animation and graphics libraries. Thomas Fuchs uses
Prototype for scriptaculous, so this might be a good thing for scripty2
which uses

Finally switching to Sizzle is interesting because it's a widely adopted
and very focused library. There are enough selector engines out there,
so the open source community won't suffer by Prototype's engine becoming

Remember that this means XPath selectors won't work. Prototype supported
XPath in browsers with document.evaluate, but Sizzle will
raise Syntax error, unrecognized expression: