]> source.dussan.org Git - jquery.git/commitdiff
Added a fix and test for bug #978 (Appending elements into an IFrame, in IE).
authorJohn Resig <jeresig@gmail.com>
Sat, 24 Mar 2007 02:03:47 +0000 (02:03 +0000)
committerJohn Resig <jeresig@gmail.com>
Sat, 24 Mar 2007 02:03:47 +0000 (02:03 +0000)
build/test/index.html
src/jquery/coreTest.js
src/jquery/jquery.js
src/selector/selectorTest.js

index 1a00fd78a8895a5f8b3ef304f25a311a6d493ab9..04255705f36557e63f6f7725f4277e5cbf0beb84 100644 (file)
@@ -79,6 +79,7 @@
                        </object>
                </form>
                <b id="floatTest">Float test.</b>
+               <iframe id="iframe"></iframe>
        </div>
        </dl>
        
index 896130011a7b69afd251466290a8b53199378268..5c982ee225b56eb6edb30c58d9d9686b8f785ca4 100644 (file)
@@ -316,7 +316,7 @@ test("wrap(String|Element)", function() {
 });\r
 \r
 test("append(String|Element|Array&lt;Element&gt;|jQuery)", function() {\r
-       expect(11);\r
+       expect(12);\r
        var defaultText = 'Try them out:'\r
        var result = $('#first').append('<b>buga</b>');\r
        ok( result.text() == defaultText + 'buga', 'Check if text appending works' );\r
@@ -353,6 +353,16 @@ test("append(String|Element|Array&lt;Element&gt;|jQuery)", function() {
        reset();\r
        $("#sap").append(document.getElementById('form'));\r
        ok( $("#sap>form").size() == 1, "Check for appending a form" );  // Bug #910\r
+\r
+       reset();\r
+       var pass = true;\r
+       try {\r
+               $( $("iframe")[0].contentWindow.document.body ).append("<div>test</div>");\r
+       } catch(e) {\r
+               pass = false;\r
+       }\r
+\r
+       ok( pass, "Test for appending a DOM node to the contents of an IFrame" );\r
        \r
 });\r
 \r
index 84a1594332674bd481be8fcdc74c5f7f63019ffa..cf9459d248c4ce19de610114e2a4eb90a33c6ba6 100644 (file)
@@ -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
index c9cf762a57f848d9bc4c0e24295e45e925c12bf4..fea247ea3642858ea1cbfa91a8210d0f1eef8c9f 100644 (file)
@@ -144,8 +144,8 @@ test("expressions - basic xpath", function() {
        t( "Attribute Exists", "//a[@title]", ["google"] );\r
        t( "Attribute Equals", "//a[@rel='bookmark']", ["simon1"] );\r
        t( "Parent Axis", "//p/..", ["main","foo"] );\r
-       t( "Sibling Axis", "//p/../", ["firstp","ap","foo","first","firstUL","empty","form","floatTest","sndp","en","sap"] );\r
-       t( "Sibling Axis", "//p/../*", ["firstp","ap","foo","first","firstUL","empty","form","floatTest","sndp","en","sap"] );\r
+       t( "Sibling Axis", "//p/../", ["firstp","ap","foo","first","firstUL","empty","form","floatTest","iframe","sndp","en","sap"] );\r
+       t( "Sibling Axis", "//p/../*", ["firstp","ap","foo","first","firstUL","empty","form","floatTest","iframe","sndp","en","sap"] );\r
        t( "Has Children", "//p[a]", ["firstp","ap","en","sap"] );\r
        \r
        $("#foo").each(function() {\r