diff --git a/jquery.pjax.js b/jquery.pjax.js index 5b56efd3..4e2bd0ee 100644 --- a/jquery.pjax.js +++ b/jquery.pjax.js @@ -684,7 +684,7 @@ function extractContainer(data, xhr, options) { } if ($fragment.length) { - obj.contents = $fragment.contents() + obj.contents = options.fragment === 'body' ? $fragment : $fragment.contents() // If there's no title, look for data-title and title attributes // on the fragment diff --git a/test/unit/pjax.js b/test/unit/pjax.js index 4b3ac0e5..9767290a 100644 --- a/test/unit/pjax.js +++ b/test/unit/pjax.js @@ -314,7 +314,7 @@ if ($.support.pjax) { frame.$('body').on('pjax:success', function(event, data) { equal(typeof data, 'string') - equal(frame.$("body > p").html().trim(), "Hello!") + equal(frame.$("body > #main > p").html().trim(), "Hello!") equal(frame.document.title, "Hello") start() })