diff options
author | John Resig <jeresig@gmail.com> | 2007-03-24 02:03:47 +0000 |
---|---|---|
committer | John Resig <jeresig@gmail.com> | 2007-03-24 02:03:47 +0000 |
commit | 0f7c89cd97de6ca644a834a119dda1e057fd724e (patch) | |
tree | a9d437fb86e7a70eaf20e94306a6335413c2885e | |
parent | 7ad613c5e9aaf79666c5de39ebfafad5c46e13b9 (diff) | |
download | jquery-0f7c89cd97de6ca644a834a119dda1e057fd724e.tar.gz jquery-0f7c89cd97de6ca644a834a119dda1e057fd724e.zip |
Added a fix and test for bug #978 (Appending elements into an IFrame, in IE).
-rw-r--r-- | build/test/index.html | 1 | ||||
-rw-r--r-- | src/jquery/coreTest.js | 12 | ||||
-rw-r--r-- | src/jquery/jquery.js | 21 | ||||
-rw-r--r-- | src/selector/selectorTest.js | 4 |
4 files changed, 28 insertions, 10 deletions
diff --git a/build/test/index.html b/build/test/index.html index 1a00fd78a..04255705f 100644 --- a/build/test/index.html +++ b/build/test/index.html @@ -79,6 +79,7 @@ </object> </form> <b id="floatTest">Float test.</b> + <iframe id="iframe"></iframe> </div> </dl> diff --git a/src/jquery/coreTest.js b/src/jquery/coreTest.js index 896130011..5c982ee22 100644 --- a/src/jquery/coreTest.js +++ b/src/jquery/coreTest.js @@ -316,7 +316,7 @@ test("wrap(String|Element)", function() { });
test("append(String|Element|Array<Element>|jQuery)", function() {
- expect(11);
+ expect(12);
var defaultText = 'Try them out:'
var result = $('#first').append('<b>buga</b>');
ok( result.text() == defaultText + 'buga', 'Check if text appending works' );
@@ -353,6 +353,16 @@ test("append(String|Element|Array<Element>|jQuery)", function() { reset();
$("#sap").append(document.getElementById('form'));
ok( $("#sap>form").size() == 1, "Check for appending a form" ); // Bug #910
+
+ reset();
+ var pass = true;
+ try {
+ $( $("iframe")[0].contentWindow.document.body ).append("<div>test</div>");
+ } catch(e) {
+ pass = false;
+ }
+
+ ok( pass, "Test for appending a DOM node to the contents of an IFrame" );
});
diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js index 84a159433..cf9459d24 100644 --- a/src/jquery/jquery.js +++ b/src/jquery/jquery.js @@ -614,10 +614,13 @@ jQuery.fn = jQuery.prototype = { */ wrap: function() { // The elements to wrap the target around - var a = jQuery.clean(arguments); + var a, args = arguments; // Wrap each of the matched elements individually return this.each(function(){ + if ( !a ) + a = jQuery.clean(args, this.ownerDocument); + // Clone the structure that we're using to wrap var b = a[0].cloneNode(true); @@ -1121,12 +1124,15 @@ jQuery.fn = jQuery.prototype = { * @cat Core */ domManip: function(args, table, dir, fn){ - var clone = this.length > 1; - var a = jQuery.clean(args); - if ( dir < 0 ) - a.reverse(); + var clone = this.length > 1, a; return this.each(function(){ + if ( !a ) { + a = jQuery.clean(args, this.ownerDocument); + if ( dir < 0 ) + a.reverse(); + } + var obj = this; if ( table && jQuery.nodeName(this, "table") && jQuery.nodeName(a[0], "tr") ) @@ -1440,8 +1446,9 @@ jQuery.extend({ return ret; }, - clean: function(a) { + clean: function(a, doc) { var r = []; + doc = doc || document; jQuery.each( a, function(i,arg){ if ( !arg ) return; @@ -1452,7 +1459,7 @@ jQuery.extend({ // Convert html string into DOM nodes if ( typeof arg == "string" ) { // Trim whitespace, otherwise indexOf won't work as expected - var s = jQuery.trim(arg), div = document.createElement("div"), tb = []; + var s = jQuery.trim(arg), div = doc.createElement("div"), tb = []; var wrap = // option or optgroup diff --git a/src/selector/selectorTest.js b/src/selector/selectorTest.js index c9cf762a5..fea247ea3 100644 --- a/src/selector/selectorTest.js +++ b/src/selector/selectorTest.js @@ -144,8 +144,8 @@ test("expressions - basic xpath", function() { t( "Attribute Exists", "//a[@title]", ["google"] );
t( "Attribute Equals", "//a[@rel='bookmark']", ["simon1"] );
t( "Parent Axis", "//p/..", ["main","foo"] );
- t( "Sibling Axis", "//p/../", ["firstp","ap","foo","first","firstUL","empty","form","floatTest","sndp","en","sap"] );
- t( "Sibling Axis", "//p/../*", ["firstp","ap","foo","first","firstUL","empty","form","floatTest","sndp","en","sap"] );
+ t( "Sibling Axis", "//p/../", ["firstp","ap","foo","first","firstUL","empty","form","floatTest","iframe","sndp","en","sap"] );
+ t( "Sibling Axis", "//p/../*", ["firstp","ap","foo","first","firstUL","empty","form","floatTest","iframe","sndp","en","sap"] );
t( "Has Children", "//p[a]", ["firstp","ap","en","sap"] );
$("#foo").each(function() {
|