登录站点

用户名

密码

注册

查看日志|返回日志列表

jQuery 1.5 正式版发布

标签正式版  2011-02-01 15:33
jQuery 1.5正式版于1月31日如期发布! jQuery是一个JavaScript库,它简化了HTML文档遍历,事件处理,动画和为网络快速发展的Ajax交互。变化包括一个重写的Ajax模块,划分 jQuery子类的能力,以及许多其他功能增强,修复各种内存泄漏,性能改进和加强跨浏览器的兼容。鼓励测试该版本的用户提供反馈和报告他们遇到的任何错误。

Right on schedule jQuery 1.5 is ready for consumption!
This release has been a long time coming and has been a real team effort. Please take this opportunity to thank members of the jQuery Team and the jQuery bug triage team for their help in getting this release out the door.

下载地址:
jQuery Minified (29kb Gzipped)
jQuery Regular (207kb)

Microsoft CDN: http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.min.js

关于jQuery 1.5

该版本修复了83个bug,解决了460个问题。

针对下列浏览器进行了测试:
Safari 5.0.3 / 4.0.5 / 3.2.3 / 3.1.2
Opera 11.01 / 11 / 10.63 / 10.54 / 10.10 / 9.64
IE 6 / 7 / 8
Firefox 4.0b9 / 3.6.13 / 3.5.11 / 3.0.19 / 2.0.0.20
Chrome 8.0.552.215 / 8.0.552.237 / 9.0.597.67 Beta / 10.0.642.2 Dev

jQuery 1.5 API文档:http://api.jquery.com/category/version/1.5/

重大改进

1. 重写了Ajax模块:

a) 提供了更高级的统一的API;

b) Ajax请求会返回一个封装不同浏览器XMLHttpRequest的jXHR对像,可以完成以前不可能完成的任务,比如:放弃JSONP请求,详见jQuery.ajax()文档;

c) 更好的扩展性,可以方便地扩展Ajax的发送与接收,管理Ajax请求,详见Extending Ajax文档。

2. 新增延缓对像(Deferred Objects)

a) 直接使用没有立即返回的返回值,比如异步Ajax请求的返回结果;

b) 附加多个事件处理器(这在以前是不可能的),示例代码:
// Assign handlers immediately after making the request,
// and remember the jxhr object for this request
var jxhr = $.ajax({ url: "example.php" })
.success(function() { alert("success"); })
.error(function() { alert("error"); })
.complete(function() { alert("complete"); });

// perform other work here ...

// Set another completion function for the request above
jxhr.complete(function(){ alert("second complete"); });

了解更多内容,请阅读Deferred Object文档。

推荐教程:Using Deferreds in jQuery 1.5

3. jQuery替身——jQuery.sub()

可以方便地创建jQuery副本,不影响原有的jQuery对像,避免jQuery冲突。示例代码如下:

(function(){
var sub$ = jQuery.sub();

sub$.fn.myCustomMethod = function(){
return 'just for me';
};

sub$(document).ready(function() {
sub$('body').myCustomMethod() // 'just for me'
});
})();

typeof jQuery('body').myCustomMethod // undefined

了解更多,请阅读jQuery.sub()文档。

4. 增强了遍历相邻节点的性能

增强的遍历方法:.children(), .prev(), .next(),究竟增强多少,请看下图:

5. jQuery开发团队构建系统的改进

现在jQuery的构建基于服务端JavaScript环境——NodeJS,以前用的是Java/Rhino。编译器用的是来自Google Closure Compiler的UglifyJS,编译后的js文件更小。

分享 483 次阅读 | 0 个评论

留下脚印

评论