来自jquery官方网站的消息
,目前最流行的JavaScript/Ajax库jQuery新版本1.4已经发布,为jQuery项目4周年14天庆祝送上一份大礼。
1.4的压缩版只有23K,未压缩版154K。此外,Google也在自己的服务器上提供了副本,作为Google Ajax API的一部分,可以直接引用。
jQuery 1.4对代码库进行了内部重写组织,开始建立一些风格规范。老的core.js文件被分为attribute.js,
css.js, data.js, manipulation.js,
traversing.js和queue.js。CSS和attribute的逻辑分离。并修正了207个老版本的错误。
主要新特性有:
1. 常用方法的性能大幅提升
。重写了大部分较早期的函数。
2. 更容易使用的设置函数
(setter function)。为所有对象新增了许多易用的设置函数。
3. Ajax方面的改进
。引入了许多Ajax和JSON处理方面的更新,包括HTML5元素的序列化。
此外,attribute(改进了.attr()的性能)、jQuery()核心函数、CSS(.css()性能有两倍提升)、特效和事件、DOM操作等也有显著改进。
翻译自:http://techie-buzz.com/internet-tools/jquery-14-released-on-4th-jquery-birthday.html
以下是官方文档:
JQuery 1.4 Roadmap
From jQuery JavaScript Library
ROUGH NOTES
This is just some rough notes for things to look at for 1.3.x/1.4.
Contents
- 1
Core - 2
DOM - 3
Selectors - 4
Attributes / CSS - 5
Data - 6
Offset - 7
Events - 8
Ajax - 9
Effects - 10
Structure - 11
Testing - 12
Misc
[edit
]
]
Core
- jQuery.require (require JavaScript modules and CSS to load before ready runs)
jQuery.require("foo.js");
jQuery.require("foo2.js");
jQuery(function(){ … });
See also xLazyLoader
- Dynamic loading of modules when they’re needed (would require synchronous script loading in core)
- $.ready failover. If not enough functionality is provided, have ready gracefully not load.
- Widget Factory
- .toArray()
(As alternative to .get()) - .get(-1)
Allow for negative numbers to .get(). - $.isObject() (Possibly for use by deep extending)
- Use $.isArray() and $.isObject() for deep extending Discussion
, Discussion - Implicit ready event like Mike Alsup is doing with his plugins now
.
[edit
]
]
DOM
- $.contains
(determine if an element is inside another one)
jQuery("div").contains(DOMElement)
- Forcefully remove html/head/body from HTML injection
- Handle HTML injection in XML documents (serialize a DOM then insert)
- Use .outerHTML to cleanup after .remove()
- Implement a .extract()/.detach() method (remove the element from the DOM, leaves events and data intact) Discussion 1
, Discussion 2 - .not() should accept a function for filtering
- .filter() should accept an Element, Selector, or Array
- .index() (no arg) gives you the position of the element amongst its siblings
- .children() should be sorted in order
- .after() should act like .add() if the elements are disconnected.
- .before() should work similarly, as well.
[edit
]
]
Selectors
- Force document order for comma-separated queries. Discussion
(In 1.3.2) - Use querySelectorAll for element-rooted queries. Discussion
- Piggy-back on a central data cache, if one exists.
- "#id p" should be as fast as $("#id").find("p")
(In 1.3.3)
[edit
]
]
Attributes / CSS
- Rewrite (reorganize and separate these two pieces of functionality) (reorganized and separated in 1.3.3)
- Use only camelCase for styles
- Related: Fix camelCase of animation styles
- Why is Math.max used in height/width? Should be removed? (Needed: IE freaks out with negative numbers)
- Use only camelCase for styles
- Deactivate alpha filter in IE when set to 1.0
- Get filter value from stylesheet for alpha
- Allowing a function as the "setter" argument for .css() –
like we have in .attr() – and maybe for .val(), .html(), and .text()
as well. - Allow retrieval of multiple attributes/styles using a space separated string
- Enhance .toggleClass
(in 1.3.3) - .radioClass()
- colSpan
[edit
]
]
Data
[edit
]
]
Offset
- Make offset and position a setter offset setter plugin
- Faster Initialization
(in 1.3.3) - Use parseFloat
(in 1.3.3) - boundingClientRect check
(in 1.3.3)
[edit
]
]
Events
- Have <img>.load check for .complete in IE (in case the file was already loaded and cached) Discussion
- Add the mousewheel event to core
- Adapt mouseenter/mouseleave to work with live
- Multiple binding with namespaces
- Event scoping Discussion
ticket
(in jQuery 1.3.3) - .live()
- $("foo", context).live(…)
(in 1.3.3, might have issues with closest method not respecting context though) - Implement .live("change") see also
- Implement .live("submit")
- Implement .live("blur/focus")
- $("foo", context).live(…)
- Do garbage collection asynchronously
- Events should be stored as an array [1]
(Also, need a ticket on Chrome executing events out of order.) - Iframe load event not possible Discussion
[edit
]
]
Ajax
- Use JSON API if available to parse JSON. More info
- Remove type cruft from $.get
- Add some extra simple arguments to $.ajax.
$.ajax(type, url, options);
- Support options argument in $.get and $.post
$.get(url, data, dataType, options);
$.post(url, data, dataType, options);
- Improved $.param serialization
- Dynamic loading of stylesheets
- Look at headers to make intelligent decisions about the content-type
[edit
]
]
Effects
- Synchronized animations
(Sync multiple animations together) - fadeTo show also show the element, if it’s hidden.
(in 1.3.3) - Animate to end value of ‘auto’
[edit
]
]
Structure
- Reduce the number of function calls needed for common jQuery methods
- Split up jQuery structure into smaller modules (core, traversing, manipulation, attributes/css)
- This was done in r6283
(for 1.3.3), although there are some dependency issues
to work out
- This was done in r6283
- Make it possible to only load the core module and be able to load all the rest dynamically
- Seems like this would force us to expose a lot of the private
methods/properties we have right now and potentially ditch the use of a
closure.
- Seems like this would force us to expose a lot of the private
- Passing the XHTML test suite
- Passing Object.prototype tests
- Cache static objects
- Standardize RegExp usage
(in 1.3.3) - Improve RegExp Callbacks
(in 1.3.3) - Working in evalInSandbox
- Keep a separate data() cache for the document object (to avoid any obvious pollution).
- Work as a Caja Gadget [2]
[3]
[edit
]
]
Testing
- Runnable DOM Ready tests
- Object.prototype tests
- Integrate test suites from plugins into jQuery test suite
[edit
]
]
Misc
- Work on the jQuery Core Style Guidelines
- Make sure that we pass Spidermonkey/Rhino Strict
- Include that check into the build process