Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added a test case for "purple include", fixed a bug.
  • Loading branch information
jeresig committed Aug 25, 2007
1 parent 34f1042 commit 0477a6e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
3 changes: 3 additions & 0 deletions build/test/data/test3.html
@@ -0,0 +1,3 @@
<div class="user">This is a user</div>
<div class="user">This is a user</div>
<div class="teacher">This is a teacher</div>
6 changes: 4 additions & 2 deletions src/ajax/ajax.js
Expand Up @@ -49,8 +49,10 @@ jQuery.fn.extend({
return this.bind("load", url);

var off = url.indexOf(" ");
var selector = url.slice(off, url.length);
url = url.slice(0, off);
if ( off >= 0 ) {
var selector = url.slice(off, url.length);
url = url.slice(0, off);
}

callback = callback || function(){};

Expand Down
9 changes: 9 additions & 0 deletions src/ajax/ajaxTest.js
Expand Up @@ -94,6 +94,15 @@ test("load(String)", function() {
$('#first').load("data/name.html", start);
});

test("load('url selector')", function() {
expect(1);
stop(true); // check if load can be called with only url
$('#first').load("data/test3.html div.user", function(){
equals( $(this).children("div").length, 2, "Verify that specific elements were injected" );
start();
});
});

test("load(String, Function) - simple: inject text into DOM", function() {
expect(2);
stop();
Expand Down

0 comments on commit 0477a6e

Please sign in to comment.