Ajax 板


LINE

※ 引述《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







like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草

请输入看板名称,例如:BabyMother站内搜寻

TOP