Commit 85afa7c1 authored by John Resig's avatar John Resig

Added support for .contents(). Returns ALL child nodes for an element - except...

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.
parent 079d651e
...@@ -996,3 +996,10 @@ test("map()", function() { ...@@ -996,3 +996,10 @@ test("map()", function() {
"Single Map" "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" );
});
...@@ -2151,7 +2151,8 @@ jQuery.each({ ...@@ -2151,7 +2151,8 @@ jQuery.each({
next: "jQuery.nth(a,2,'nextSibling')", next: "jQuery.nth(a,2,'nextSibling')",
prev: "jQuery.nth(a,2,'previousSibling')", prev: "jQuery.nth(a,2,'previousSibling')",
siblings: "jQuery.sibling(a.parentNode.firstChild,a)", 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){ }, function(i,n){
jQuery.fn[ i ] = function(a) { jQuery.fn[ i ] = function(a) {
var ret = jQuery.map(this,n); var ret = jQuery.map(this,n);
......
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