Prototype 1.6 final... and more
I’m really really happy to announce Prototype 1.6 final today. We’ve put huge amounts of effort and love into it. It’s a great release and I’m sure you will love it.
I’d like to take that opportunity to thank all the users and contributors who’ve filed bug reports, posted patches and generally helped with the development and testing.
But there’s more:
Thomas Fuchs just announced script.aculo.us 1.8 final, which is of course fully based on Prototype 1.6.
… and Christophe Porteneuve’s book, Prototype & script.aculo.us, has just been completed and is now available for purchase from the Pragmatic Programmers. It’s fully up to date with both Prototype 1.6 and script.aculo.us 1.8. Go get it now!
Remember: copywriting is interface design
I had a pretty tragic laptop incident last week, and I am still migrating data from my old, severely damaged hard drive to my new laptop.
Wanted to check back into my Flickr account today - which I had created a while ago via my Yahoo! account (or so I thought). Anyway, I probably either couldn’t find the right password or the right login, and ended up facing this rather contradictory injunction:

Should it be different… or can it be different (implying it definitely could be identical).
Remember: copywriting is interface design!
JavaScript quirks
Nearly got burnt by a surprising behavior of JavaScript. We probably all know by now that null, the integer 0, '' (the empty string) and undefined are evaluated as false inside an if statement. What's a bit more curious is the following behaviour (try it the firebug console):
false == 0;
// -> true
false == '';
// -> true
false == undefined;
// -> false
false == null;
// -> false
If anyone has a rationale explanation to this, please share.
Prototype Quick Tip
Living on the edge and using Prototype’s latest DOM Builder ? Feeling a bit dirty doing the following:
new Element('div').update('some text...');
// --> <div>some text...</div>
Here’s a quick solution (using Element.addMethods) to fully dwell in complete web-standardness:
Element.addMethods({
appendText: function(element, text) {
element = $(element);
text = String.interpret(text);
element.appendChild(document.createTextNode(text));
return element;
}
});
Best part is that it lets you append anything, as long as the text argument has a toString method (thanks to Ash Searle for suggesting a better handling of null and undefined):
new Element('div').appendText('Some more text.');
// --> <div>Some more text.</div>
new Element('div').appendText(123);
// --> <div>123</div>
swedish poiuyt
Just a hilarious Escher/Oscar Reutersvärd (yet another swede!) inspired snapshot stolen from Christian Heilmann’s slides for his Seven Reasons for Code Bloat presentation for the WSG London Meet-up.

Couldn’t resist. Hope he doesn’t mind.
The Bungee Book

Christophe Proteneuve, one of my fellow Prototype Core Team, member, just published the first Beta Book of Prototype and script.aculo.us - You never knew JavaScript could do this! over at the Pragmatic Programmers. (You can read more about the whole beta book concept on their website).
Affectionately dubbed “The Bungee Book” by Sam Stephenson–the master mind behind Prototype–Christophe’s upcoming title is sure to become the reference for Prototype and Script.aculo.us developers across the world.
I’ve had the chance to read through the first beta and all I can say is that you’d be just plain stupid not to grab a copy now: It’s thorough, extremely well documented (no wonder, Christophe wrote his share of the docs, trust me!) and witty.
Not only does Christophe know Prototype and script.aculo.us inside-out, he’s also very much in touch with both of their communities and it shows: there’s stuff for everyone in there, from the beginner (some solid JavaScript basis strongly suggested, though) to the seasoned pro ready to start contributing code.
Check it out, you won’t regret it!
The Gut Factor
Seen on project.ioni.st today:
The feeling I get when programming is at least as important as other factors when selecting a language.
Chad Fowler
That’s what I refer to as the gut factor. And which is what made me stick with Prototype when no documentation was available, updates were scarce, and people were migrating en masse to jQuery and YUI.
Looking back, that was one of the wisest decisions I made: I learnt way more about JavaScript helping out with the documentation and joining the Core Team than I would have otherwise.
What about you. What factors pushed you to adopt the language, framework, or library that your are using today ?
DOS attack on jQuery
The web is a place full of surprises. And sometimes they aren’t good ones.
Most of you know jQuery, John Resig’s excellent JavaScript library, well… the website it’s hosted on has been the subject of DOS attack over the week-end, and its host kindly invited John to go look for hosting elsewhere.
jQuery has now found a new host, (you might still encounter issues connecting to it while the DNS propagates), but the move was costly and Learning jQuery is still collecting funds to cover the move.
Please consider chipping in a dime or two.
Prototype 1.5.1 release candidate 3

We've just released Prototype 1.5.1_rc3, here's what's new since release candidate 2:
Bug fixes
Element.addMethodsnow also again adds the methods to Element. [#7888]Form.requestalso works with forms containing an input element withname="action". [#8063]- Safari no longer crashes on
String#stripScriptsandextractScriptswith large<script>. Form.disableworks again on non-form elements. [#6887]String#endsWithnow always returns the correct value. [#7822]- Ajax responses with no Content-type header are no longer evaluated. [#7827]
Hash#toQueryStringagain serializes undefined values to ensure consitency withString#toQueryParams. [#7806]- Various fixes of the
$$()utility. [#7873], [#7901]
Enhancements
- Ajax.Requests now supports per-request
onCreatecallbacks. [#8011] - JSON strings are automatically stripped of their security delimiters (if present) before
eval. More details on this security issue here (PDF document). [#7910] - all
toJSONmethods now generate YAML-loadable JSON. [#7883] Event.elementnow returns an extended element. [#7870]- Linefeed normalisation is now prevented in IE on
String#escapeHTMLandString#unescapeHTMLfor consistency with other browsers. - Added a new
Element.childElementsmethod (shorter alias ofElement.immediateDescendants). - Added a new
Element.firstDescendantmethod (same as usingElement.downwith no arguments).
Performance
- Faster
$$()utility andElement.getElemementsBySelectormethod. [#7873], [#7901] - Optimized
Element.next,Element.down,Element.upandElement.previousDOM methods. [#7848] - Speed improvements of
String#escapeHTMLandString#unescapeHTMLin IE and Safari.
You can also view the full changelog to see all of what has been improved since version 1.5.0.
If all goes well, this will be the last release candidate before 1.5.1 final, so we're counting on everyone's zealous testing and bug reporting.
Go download it now!
Rico 2.0 beta 1 is out

Rising back from the dead, the UI JavaScript library Rico just released a first beta of their upcoming version 2.0, which you can download from their website.
It’s based on the latest release of Prototype (version 1.5.1_rc2) which is included in the download.
I am really, really happy to see this project alive again, as yet another example of the striving Prototype community.
It’s the best reward we could get for the work we’ve put into Prototype 1.5 and the documentation site.
Thanks Richard for pursuing your great work and making it available to the community, and welcome to your new contributor: Matt Brown.
Sanitize JSON regexp bug
Following my last post on a critical Safari's regexp bug (it actually crashes the browser), Andy Armstrong suggested a partial solution to the problem:
Here's a tentative fix to JSON's sanitize regexp based on it:
/^("(\.|[^"\\n\r]*)*?"|[,:{}[]0-9.\-+Eaeflnr-u \n\r\t]*)+?$/
instead of the original:
/^("(\.|[^"\\n\r])*?"|[,:{}[]0-9.\-+Eaeflnr-u \n\r\t])+?$/
Although it does not entirely solve the problem, it does allow longer strings to be parsed without crashing Safari.
Again, your mileage may vary depending on your machine.
Here's a test-case for it.
Any improvements, suggestions, etc. are warmly welcomed.
Yet another safari bug
This one's pretty annoying:
/(.)+/.test(string);
This crashes Safari when string's length is bigger than about 7000 characters (your mileage may vary, it looks like the exact size is machine dependent, but its in that area on an intel MacBook).
The cause of the crash seems to be the length of the grouping results, as this works fine:
/.+/.test(string);
UPDATE: Non-capturing parentheses do not solve this bug. So this:
/(?:.)+/.test(string);
will still crash Safari.
This bug has some really annoying consequences. While we managed to fix some of them in the Prototype framework, it still leaves the issue of JSON sanitizing.
Currently, this is done both in Prototype and in Douglas Crockford's original implementation, (on which Prototype is mapped) by the following regex:
/^("(\.|[^"\\n\r])*?"|[,:{}[]0-9.\-+Eaeflnr-u \n\r\t])+?$/
which unfortunately chokes on long strings.
The only solution I can see to this problem right now is to use Prototype's implementation without the sanitizing parameter, e.g.:
string.evalJSON(); // <-- this will work
string.evalJSON(true); // <-- this won't!
Any brilliant suggestion is of course welcomed.
UPDATE: I forgot to mention that this was fixed in WebKit.
UPDATE: I've added a small testcase.
UPDATE: There's a follow-up more directly targeted at the JSON issue here.
quick and dirty ascii "spinner"
Element.addMethods({
loading: function(element) {
element = $(element);
element._innerHTML = element.innerHTML;
element.update();
element._interval = window.setInterval(
function(){
var html = this.innerHTML;
this.update(html.length > 2 ? '' : html + '.');
}.bind(element), 100)
return element;
},
stopLoading: function(element, revert) {
element = $(element);
window.clearInterval(element._interval);
if(revert) element.update(element._innerHTML);
element._innerHTML = element._interval = undefined;
return element;
}
});
Rico 2.0

Looks like Rico - a UI JavaScript lib built on top of Prototype - is getting ready for a long awaited 2.0 release.
As seen on their website:
Site Update and Rico 2.0.
We are updating the site to support Rico 2.0. We have also suffered some server troubles.
Please bear with us as we prepare the site for the new release.
I’m really looking forward to find out what Richard Cowin and team have been cooking.
