Added a test case for "purple include", fixed a bug.
authorJohn Resig <jeresig@gmail.com>
Sat, 25 Aug 2007 03:55:12 +0000 (03:55 +0000)
committerJohn Resig <jeresig@gmail.com>
Sat, 25 Aug 2007 03:55:12 +0000 (03:55 +0000)
build/test/data/test3.html [new file with mode: 0644]
src/ajax/ajax.js
src/ajax/ajaxTest.js

diff --git a/build/test/data/test3.html b/build/test/data/test3.html
new file mode 100644 (file)
index 0000000..909d417
--- /dev/null
@@ -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>
index 795cd8a..ccf4f14 100644 (file)
@@ -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(){};
 
index 4d4bc07..0fd4888 100644 (file)
@@ -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();