开发者

jquery attr behaviour in version 1.6

I have made a page here

It was working fine with vers开发者_如何学Pythonion 1.5

now with 1.6 i m getting this error in firebug

 elem.getAttribute is not a function
 [Break On This Error] ret = elem.getAttribute( name ); 

and in chrome almost the same

 Uncaught TypeError: Object #<HTMLDocument> has no method 'getAttribute'

How do rectify it?? Do i have to change everything to prop as in jquery 1.6 api http://api.jquery.com/prop/


The problem is, I think, in your library jquery.getUrlParam.js. This has lines like the following:

if ($(this).attr("nodeName")=="#document") {

This worked under jQuery <= 1.5, because attr used both properties and attributes. jQuery 1.6 has cleared this confusion up, which has created some problems for code that relied on this behaviour. This is an example of code that has broken because of the change.

The correction would be

if (this.nodeName === "#document") {

You should be able to fix this in your code; it's probably also wise to report it to the plugin author.

A further point is that jQuery should probably give a better error message when trying attr on the document object, because the document node (unlike element nodes), does not have a getAttribute method. This is the cause of your mysterious error message.


Edit 11 May The error here looks like being fixed in jQuery 1.6.1. This commit to the jQuery source means that jQuery falls back on the prop method if the selected node does not have a getAttribute method.

This, along with the other changes in 1.6.1 should make upgrading from <1.6 to 1.6.1 seamless.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜