@@ -642,20 +642,25 @@ function optionsFor(container, options) {
642
642
// Because we can't persist elements using the history API, we must be
643
643
// able to find a String selector that will consistently find the Element.
644
644
//
645
- // container - A selector String, jQuery object, or DOM Element .
645
+ // container - A selector String or jQuery object .
646
646
//
647
647
// Returns a jQuery object whose context is `document` and has a selector.
648
648
function findContainerFor ( container ) {
649
- container = $ ( container )
650
-
651
- if ( ! container . length ) {
652
- throw "no pjax container for " + container . selector
653
- } else if ( container . selector !== '' && container . context === document ) {
654
- return container
655
- } else if ( container . attr ( 'id' ) ) {
656
- return $ ( '#' + container . attr ( 'id' ) )
649
+ var formatedContainer
650
+
651
+ if ( jQuery . type ( container ) === 'string' ) {
652
+ formatedContainer = $ ( container )
653
+ formatedContainer . selector = container
657
654
} else {
658
- throw "cant get selector for pjax container!"
655
+ formatedContainer = container
656
+ }
657
+
658
+ if ( ! formatedContainer . length ) {
659
+ throw "no pjax container for " + container
660
+ } else if ( ! formatedContainer . selector ) {
661
+ throw "cant get selector for pjax container"
662
+ } else {
663
+ return formatedContainer
659
664
}
660
665
}
661
666
@@ -911,8 +916,11 @@ function disable() {
911
916
912
917
// Add the state property to jQuery's event object so we can use it in
913
918
// $(window).bind('popstate')
914
- if ( $ . inArray ( 'state' , $ . event . props ) < 0 )
919
+ if ( $ . event . props && $ . inArray ( 'state' , $ . event . props ) < 0 ) {
915
920
$ . event . props . push ( 'state' )
921
+ } else if ( ! ( 'state' in $ . Event . prototype ) ) {
922
+ $ . event . addProp ( 'state' )
923
+ }
916
924
917
925
// Is pjax supported by this browser?
918
926
$ . support . pjax =
0 commit comments