码迷,mamicode.com
首页 > Web开发 > 详细

PJax在jQuery 3.0无法运行问题修复

时间:2016-12-02 18:49:47      阅读:441      评论:0      收藏:0      [点我收藏+]

标签:lan   remove   log   pre   ase   list   ide   handler   migrate   

PJax在jQuery 3.0无法运行

【现象】

页面报错:Uncaught TypeError: Cannot read property ‘push‘ of undefined

【原因】

jQuery3.0开始去除了$.event.props

Breaking change: jQuery.event.props and jQuery.event.fixHooks removed

jQuery‘s event handling performance increased thanks to a reorganization of event property management. The main improvement is that jQuery now only calculates or copies a property on the first access, rather than calculating and copying them up front. This is a really big win with properties that may force layout that the event handler may not even need. The most common use we know of was to add properties for pointer events, which is no longer necessary because those events are supported already in jQuery 3.0. The jQuery Migrate plugin provides support for these properties if you still need them. The related but undocumented mouseHooks and keyHooks lists were removed as well. The team is interested in understanding other use cases before defining new APIs, so feel free to open a ticket.

 【修改】

方法一:用addProp代替 props.push。

if ( $.event.props && $.inArray(‘state‘, $.event.props) < 0 ) {
  $.event.props.push(‘state‘);
} else if ( ! (‘state‘ in $.Event.prototype) ) {
  $.event.addProp(‘state‘);
}

方法二:使用jQuery 3.0 的migrate版本

 

参见GitHub,PJax官网 issue 634.

 

PJax在jQuery 3.0无法运行问题修复

标签:lan   remove   log   pre   ase   list   ide   handler   migrate   

原文地址:http://www.cnblogs.com/dcchan/p/6126548.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!