作者TonyQ (沉默是金。)
看板Ajax
标题Re: [情报] jQuery 1.4.4 release
时间Mon Nov 15 01:36:23 2010
※ 引述《TonyQ (沉默是金。)》之铭言:
: 一个措手不及差点就错过了....
: http://blog.jquery.com/2010/11/11/jquery-1-4-4-release-notes/
: 大部分看起来都是 bug fix , 有几个 enhance 蛮有趣的 ,
: 刚好周末到了 , 这两天找看看有没有时间来翻一下 .
: 看 release note 第一个吸引我的是这个
: .width() and .height()
: now report the width and height of hidden elements
: detail 有空再说。:D
简单翻译跟描述
有蛮大部分是改用 qSA 造成的不相容情形,果然世界没有这麽美好。:~
---
这次看来比较多是bug fix 跟 enhance ,新功能只有一个。
新功能(new feature)
.fadeToggle()
就像slideToggle跟 toggleClass 一样,现在我们有了个 fadeToggle,使用fade效果切
换显示与否。
详细说明
http://api.jquery.com/fadeToggle/
异动(Changes)
(Enh) Calling .data() with no arguments now includes data from HTML5 data-
attributes (#7222)
现在呼叫没有参数的 .data() ,将会把html5 规格上的data-attributes 也列进来了。
(不知道data-attributes的可以去看 1.4.3 的 release note,
这是该版加入的feature。)
(Enh) Moved jQuery.props from support.js to attributes.js (#6897)
结构整理 , jQuery.props 从 support.js 到 attributes.js ,
不过这对直接使用整包的人来讲应该没差.
(Enh) .width() and .height() now report the width and height of hidden
elements (#7225)
.width() 跟 .height() 现在将会回报「隐藏中」(display:none;)的元素的宽高。
(因为之前有bug 说会回传不正确(NAN)或负数的宽高)
这个是我第一眼觉得很有亮点的东西,
因为这东西其实蛮难算的,做久的人就会知道我在讲什麽;
这里有一些值得讲的,这个功能的原理蛮有趣的,他其实主要也没有做特别的trick,
他一样是拿offsetWidth跟offsetHeight .
他会先用做一个 table 里面放一个 hidden td,另一个放正常的,
塞到body去去用jQuery 拿拿看隐藏的是不是拿得到,
接下来把第一个显示,第二个隐藏,再确认拿得到高是不是正确的,
如果是,那他就会认为这结果是可靠的,所以这功能要搭配
jQuery.support.reliableHiddenOffsets 这个测试结果用才行,
这也是 jQuery 从 1.2 开始就有的观念,
测试功能是否支援,而不测试是否是特定浏览器。
根据原码所说明的,这个功能在 ie8以下并没有通过测试,所以ie8以下还是要小心。
如果你用 ie8 看这个属性值,就会发现拿到的是false.
http://jsfiddle.net/ExtjP/
详情请洽原码 1060 行
(Bug) stopImmediatePropagation was not being honoured in live/delegate event
handlers (#7217)
这个问题我想直接看issue tracker 比较快
http://bugs.jquery.com/ticket/7217
(Bug) Fixed an issue where host and protocol were not compared
case-insensitively when determining whether an AJAX request was local or
remote (#6908)
当判断一个ajax request 是同domain (local)或者不同domain(remote) 的时,没有考虑
到大小写相异情形的bug。
(Bug) Fixed an issue where the “clone” variable was not being declared
correctly (#7226)
看起来是个单纯的 type error...忘了定义变数。
(Bug) Fixed a bug where we only change the ID on nodes that don’t already
have an ID for rooted qSA (#7212)
这个也蛮有趣的,这个是我在 1.4.3 release note 中有带过
一些对 querySelectorAll 的 workaround 带来的副作用,
qSA 因为某些不为人知的理由要求一定要有一个root 才能用selector 查询其子元素,
所以过去 jQuery 1.4.3 一律采用 "__sizzle__" 作为预设的 id 来做查询;
但这样造成了一些副作用,会导致某些状况下selector会炸掉
(reproduce case请看 bug tracker
http://bugs.jquery.com/ticket/7212)
於是现在改成如果他本来就有id就用他本来的,没有的话再用预设的 __sizzle__ 。
commit log
https://github.com/jeresig/sizzle/commit/b758239
(Bug) Limited the scope of the CSS ‘auto’ change to just height/width
(#7393)
这个问题是要解决当 width 变成 "" 或 auto 时,到底该怎麽处里这个值的延伸问题,
不过这个问题我觉得我的理解不够完整,不多做说明。
(Bug) Fixed a bug to ensure that unquoted attribute selectors are quoted
(allowing them to go into qSA/matchesSelector properly). Fixes (#7216)
这个问题是个 selector 的规格问题,过去我们用attribute selector时,
并不会要求一定要加上引号,比方说 $("[name=hi]") 。
事实上在正式的规格中,应该是 $("[name='hi']"),
有些时候你不这样写也不行,像是你在处理一堆 name="hi[]" 的 radio button之类时。
原本jQuery 是两种都吃,但问题来了,
现在整 querySelectorAll/matchesSelector ,他们都只吃有quote 的版本。
使用者在 bug tracker上抱怨 jQuery 文件上明明就写两种都可以吃,
我觉得这段tracker蛮值得看得,一开始有人坚持这是原本的规格就有问题,
不过看起来最後还是选择妥协,用regex的方式做向下相容。 XD
(Bug) Fixed a bug to ensure that if additional load events are triggered (eg.
an iframe being dynamically injected in DOM ready) the ready event isn’t
triggered twice (#7352).
修正当你在 jQuery ready event 中又对dom元素加入会触发load event的东西(像
iframe),可能会导致ready event 被呼叫两次。
(Bug) Fixed a condition that prevents attr from working on non-Element nodes
(#7451).
修正这个情境下 attribute 出现的问题
$(document)[0].nodeName; // Returns "
#document"
$(document).attr("nodeName"); // (Now) Returns undefined
(Bug) Changing an HTML5 data attribute after calling .data(‘foo’) no longer
causes .data(‘foo’) to also change (#7223)
修正一个问题,说明如下:
在拿完 data attribute 之後,根据官方说明文件是拿了就不会再理dom attribute,
他会存到自己内部的元素,但是这个行为并没有正确实装,
在这个case ,
http://jsfiddle.net/jitter/CzNSq/
当他再用dom.setAttribute("data-foo","hi") 去设值,
拿到的还是data attribute 新的值,并不像 jQuery 文件所说的是只拿一次就不理了。
(Bug) Fixed a bug where Opera didn’t give height/width of display: none
elements with getComputedStyle but did with currentStyle – fall back to that
if it exists added.
opera在取得隐藏(display:none)物件的宽高上,
getComputedStyle跟currentStyle有不同的行为,取用比较正确的currentStyle。
(Bug) Fixed a bug to ensure accessing computed CSS for elements returns
‘auto’ instead of ” consistently (#7337)
更一致地让 css 属性碰到 "" 时都回传成 auto。
== 1.4.2 没有,因为升级 1.4.3 後所造成的 bug 修正 (regressions )
(Bug) JSONP calls to fail when cleaning up after a callback (#7196)
就字面上说的, jsonp 的 callback 有点问题。还原到先前的版本。
(Bug) .removeData() to fail (#7209)
removeData() 本来应该要把data()里面的东西都干掉但她没有,
官方说这是因为1.4.2 後某些理由做了一些更新但导致了另一个问题,所以改回来了。
http://bugs.jquery.com/ticket/7209
(Bug) “ready” events to fire twice when added using .bind(“ready”, foo)
(#7247)
ready event 某些情境下,原本在1.4.2只发生一次的,在1.4.3 被发了两次。
(Bug) .css(‘width’) and .css(‘height’) to return 0 or negative values
when trying to get the style of a hidden or disconnected element (#7225)
这在1.4.4 的feature 上有提过这问题了。
(Bug) the attribute not equals selector ([foo!=bar]) to not work in Firefox
(#7243)
在Firefox 某些情境下 , attribute 不等於的selector 不能作用。
(原因是因为这本来就不是个合法的css selector...qSA就不理他了)
在 1.4.3 不正确的状况是这样
http://www.jsfiddle.net/HngRv/4/
(只发生在firefox)
(Bug) find() to fail when selecting from forms containing inputs named “id”
(#7212)
前面提过了。
(Bug) .children(selector) to fail on XML documents (#7219)
matchesSelector 跟 qSA 不支援对 xml处理,所以造成这些现象。
修正成不用mS跟qSA去处理xml,改用旧的引擎处理。
(Bug) child (>), next sibling (+), and previous sibling (~) selectors to fail
when combined with non-CSS pseudo-selectors like :last (#7220)
因为 qSA 的support 问题,所以将这些selector都走回原本的 sizzle 的引擎去处理。
(Bug) an error “handler is null” to be raised when passing null as the
event handler (#7229)
不用解释了吧 XD
$("body").click(null); 会喷一个 handler is null 的error,有使用者不喜欢这样。
(Bug) it to be impossible to include a content-body with DELETE requests
(#7285)
(Bug) it to be impossible to include data with HEAD requests (#7285)
上面这两个都算是个规格问题,
在DELETE、HEAD这两个Http method 到底应不应该要不要有 body 的问题,
绝大多数人都只会用到GET/POST,除非你有用到D跟H这两个,否则这个bug fix可以跳过。
(Bug) an issue where IE was firing click events on disabled elements when
using live/delegate (#6911)
奇怪,这个bug 在tracker上没有被关掉啊......
不过这问题应该跟live event原理有关,因为他是透过注册父元素的事件,
再由 event bubbling 往上传递所达成的功能,
可能在这过程中应该要有个事件被拦截但没有。
(Bug) .show() to fail if .hide() was first called on an already-hidden
element (#7331)
这个问题在 tracker 上看起来是个对规格认知不同的结果。
(Bug) .show() to fail if an element was hidden in a stylesheet, then had .css(
‘display’) manually set prior to calling .show() (#7315)
reproduce case
http://jsfiddle.net/rwaldron/RxP32/2/
不过这个reproduce case 我在chrome跟ff上跑不出来,真是个谜...
---
btw jQuery bug trackker 全面采用 jsfiddle 作为bug重演工具...
在 notepad++ 打好贴上来好像排版有点乱了,请将就着看吧。orz
--
我:一半的日子让你说,我听你说你的所有
______________________________________
______________________________________一半的日子我想说,对你说过去的所有:我
_______________________________________________________
在讨论中妥善扮演兼具聆听与分享的角色,是我们一生的课题。
_______________________________________________________
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 114.136.198.163
※ 编辑: TonyQ 来自: 114.136.198.163 (11/15 01:37)
※ 编辑: TonyQ 来自: 220.133.44.37 (11/15 15:35)
※ TonyQ:转录至看板 Web_Design 11/15 15:35
1F:推 iam87king:推一个 11/15 20:44
2F:推 mesak:推 用心 11/16 00:24
3F:推 tomin:看得真仔细 11/16 01:05