]> source.dussan.org Git - jquery.git/commitdiff
Added support for .contents(). Returns ALL child nodes for an element - except for...
authorJohn Resig <jeresig@gmail.com>
Fri, 31 Aug 2007 03:38:02 +0000 (03:38 +0000)
committerJohn Resig <jeresig@gmail.com>
Fri, 31 Aug 2007 03:38:02 +0000 (03:38 +0000)
src/jquery/coreTest.js
src/jquery/jquery.js

index 40be7f87057c0a626179e3556a7bc26b9e3efc51..d673711aa8a209baace6a5567f690ee2b453d045 100644 (file)
@@ -996,3 +996,10 @@ test("map()", function() {
                "Single Map"
        );
 });
+
+test("contents()", function() {
+       expect(3);
+       equals( $("#ap").contents().length, 9, "Check element contents" );
+       ok( $("#iframe").contents()[0], "Check existance of IFrame document" );
+       ok( $("#iframe").contents()[0].body, "Check existance of IFrame body" );
+});
index 8180a4ea217d0fa4076091ec527abf3c1fa7c608..7cd07306b7282bf7d65bc77a1b944bbc3a33f999 100644 (file)
@@ -2151,7 +2151,8 @@ jQuery.each({
        next: "jQuery.nth(a,2,'nextSibling')",
        prev: "jQuery.nth(a,2,'previousSibling')",
        siblings: "jQuery.sibling(a.parentNode.firstChild,a)",
-       children: "jQuery.sibling(a.firstChild)"
+       children: "jQuery.sibling(a.firstChild)",
+       contents: "jQuery.nodeName(a,'iframe')?a.contentDocument||a.contentWindow.document:jQuery.makeArray(a.childNodes)"
 }, function(i,n){
        jQuery.fn[ i ] = function(a) {
                var ret = jQuery.map(this,n);