作者TonyQ (沉默是金。)
看板Web_Design
標題Re: [情報] jQuery 1.4.4 release
時間Mon Nov 15 15:35:37 2010
※ [本文轉錄自 Ajax 看板 #1Cu1uQ0S ]
作者: 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)
--
I am a person, and I am always thinking .
Thinking in love , Thinking in life ,
Thinking in why , Thinking in worth.
I can't believe any of what ,
I am just thinking then thinking ,
but worst of all , most of mine is thinking not actioning...
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.133.44.37
推 knuckles:推一個 (。ㄧ゚)b 11/15 16:55
推 shadowjohn:謝大大無私的分享~ 11/15 17:33
推 hans5300609:大推~~~~~~~~~ \( ̄▽ ̄)/ 11/15 18:10