aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohn Resig <jeresig@gmail.com>2007-08-31 03:38:02 +0000
committerJohn Resig <jeresig@gmail.com>2007-08-31 03:38:02 +0000
commit85afa7c1ba32e2e867b89e4222a4d27ea97dd20d (patch)
treebec8dbe7a8c6810fd2b62f74e3bdbe3bd180e1c5 /src
parent079d651e10bc19a28c49945617e842415dc41981 (diff)
downloadjquery-85afa7c1ba32e2e867b89e4222a4d27ea97dd20d.tar.gz
jquery-85afa7c1ba32e2e867b89e4222a4d27ea97dd20d.zip
Added support for .contents(). Returns ALL child nodes for an element - except for on an IFrame, then it returns the IFrame's document. This fixes #1024.
Diffstat (limited to 'src')
-rw-r--r--src/jquery/coreTest.js7
-rw-r--r--src/jquery/jquery.js3
2 files changed, 9 insertions, 1 deletions
diff --git a/src/jquery/coreTest.js b/src/jquery/coreTest.js
index 40be7f870..d673711aa 100644
--- a/src/jquery/coreTest.js
+++ b/src/jquery/coreTest.js
@@ -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" );
+});
diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js
index 8180a4ea2..7cd07306b 100644
--- a/src/jquery/jquery.js
+++ b/src/jquery/jquery.js
@@ -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);