Commit 48837b92 authored by Dave Methvin's avatar Dave Methvin

Ajax: .load() should trim its selector

Fixes #14773
(cherry picked from commit 3a68c114)

Conflicts:
	src/ajax/load.js
parent c93b174b
...@@ -25,7 +25,7 @@ jQuery.fn.load = function( url, params, callback ) { ...@@ -25,7 +25,7 @@ jQuery.fn.load = function( url, params, callback ) {
off = url.indexOf(" "); off = url.indexOf(" ");
if ( off >= 0 ) { if ( off >= 0 ) {
selector = url.slice( off, url.length ); selector = jQuery.trim( url.slice( off ) );
url = url.slice( 0, off ); url = url.slice( 0, off );
} }
......
<div class="user">This is a user</div> <div class="user">This is a user</div>
<div class="user">This is a user</div> <div class="user">This is a user</div>
<div class="teacher">This is a teacher</div> <div class="teacher">This is a teacher</div>
<div id="superuser">This is a superuser</div>
...@@ -1850,6 +1850,14 @@ module( "ajax", { ...@@ -1850,6 +1850,14 @@ module( "ajax", {
}); });
}); });
// Selector should be trimmed to avoid leading spaces (#14773)
asyncTest( "jQuery.fn.load( URL_SELECTOR with spaces )", 1, function() {
jQuery("#first").load( "data/test3.html #superuser ", function() {
strictEqual( jQuery( this ).children("div").length, 1, "Verify that specific elements were injected" );
start();
});
});
asyncTest( "jQuery.fn.load( String, Function ) - simple: inject text into DOM", 2, function() { asyncTest( "jQuery.fn.load( String, Function ) - simple: inject text into DOM", 2, function() {
jQuery("#first").load( url("data/name.html"), function() { jQuery("#first").load( url("data/name.html"), function() {
ok( /^ERROR/.test(jQuery("#first").text()), "Check if content was injected into the DOM" ); ok( /^ERROR/.test(jQuery("#first").text()), "Check if content was injected into the DOM" );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment