Skip to content

Commit

Permalink
jQuery 3 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
olemoign authored and mislav committed May 18, 2017
1 parent d76e840 commit 3f7859d
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions jquery.pjax.js
Expand Up @@ -642,20 +642,25 @@ function optionsFor(container, options) {
// Because we can't persist elements using the history API, we must be
// able to find a String selector that will consistently find the Element.
//
// container - A selector String, jQuery object, or DOM Element.
// container - A selector String or jQuery object.
//
// Returns a jQuery object whose context is `document` and has a selector.
function findContainerFor(container) {
container = $(container)

if ( !container.length ) {
throw "no pjax container for " + container.selector
} else if ( container.selector !== '' && container.context === document ) {
return container
} else if ( container.attr('id') ) {
return $('#' + container.attr('id'))
var formatedContainer

if (jQuery.type(container) === 'string') {
formatedContainer = $(container)
formatedContainer.selector = container
} else {
throw "cant get selector for pjax container!"
formatedContainer = container
}

if (!formatedContainer.length) {
throw "no pjax container for " + container
} else if (!formatedContainer.selector) {
throw "cant get selector for pjax container"
} else {
return formatedContainer
}
}

Expand Down Expand Up @@ -911,8 +916,11 @@ function disable() {

// Add the state property to jQuery's event object so we can use it in
// $(window).bind('popstate')
if ( $.inArray('state', $.event.props) < 0 )
if ($.event.props && $.inArray('state', $.event.props) < 0) {
$.event.props.push('state')
} else if (!('state' in $.Event.prototype)) {
$.event.addProp('state')
}

// Is pjax supported by this browser?
$.support.pjax =
Expand Down

0 comments on commit 3f7859d

Please sign in to comment.