- reset();\r
- stop();\r
- $('#check1').click(function() { \r
- var checkbox = this; \r
- ok( !checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );\r
- $(checkbox).wrap( '<div id="c1" style="display:none;"></div>' );\r
- ok( !checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );\r
- // use a fade in to check state after this event handler has finished\r
- $("#c1").fadeIn(function() {\r
- ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );\r
- start();\r
- });\r
- }).click();\r
-});\r
-\r
-test("append(String|Element|Array<Element>|jQuery)", function() {\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
- ok( $('#select3').append('<option value="appendTest">Append Test</option>').find('option:last-child').attr('value') == 'appendTest', 'Appending html options to select element');\r
- \r
- reset();\r
- expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:";\r
- $('#sap').append(document.getElementById('first'));\r
- ok( expected == $('#sap').text(), "Check for appending of element" );\r
- \r
- reset();\r
- expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";\r
- $('#sap').append([document.getElementById('first'), document.getElementById('yahoo')]);\r
- ok( expected == $('#sap').text(), "Check for appending of array of elements" );\r
- \r
- reset();\r
- expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";\r
- $('#sap').append($("#first, #yahoo"));\r
- ok( expected == $('#sap').text(), "Check for appending of jQuery object" );\r
-\r
- reset();\r
- $("#sap").append( 5 );\r
- ok( $("#sap")[0].innerHTML.match( /5$/ ), "Check for appending a number" );\r
-\r
- reset();\r
- $("#sap").append( " text with spaces " );\r
- ok( $("#sap")[0].innerHTML.match(/ text with spaces $/), "Check for appending text with spaces" );\r
-\r
- reset();\r
- ok( $("#sap").append([]), "Check for appending an empty array." );\r
- ok( $("#sap").append(""), "Check for appending an empty string." );\r
- ok( $("#sap").append(document.getElementsByTagName("foo")), "Check for appending an empty nodelist." );\r
- \r
- 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
-test("appendTo(String|Element|Array<Element>|jQuery)", function() {\r
- expect(5);\r
- var defaultText = 'Try them out:'\r
- $('<b>buga</b>').appendTo('#first');\r
- ok( $("#first").text() == defaultText + 'buga', 'Check if text appending works' );\r
- ok( $('<option value="appendTest">Append Test</option>').appendTo('#select3').parent().find('option:last-child').attr('value') == 'appendTest', 'Appending html options to select element');\r
- \r
- reset();\r
- expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:";\r
- $(document.getElementById('first')).appendTo('#sap');\r
- ok( expected == $('#sap').text(), "Check for appending of element" );\r
- \r
- reset();\r
- expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";\r
- $([document.getElementById('first'), document.getElementById('yahoo')]).appendTo('#sap');\r
- ok( expected == $('#sap').text(), "Check for appending of array of elements" );\r
- \r
- reset();\r
- expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";\r
- $("#first, #yahoo").appendTo('#sap');\r
- ok( expected == $('#sap').text(), "Check for appending of jQuery object" );\r
-});\r
-\r
-test("prepend(String|Element|Array<Element>|jQuery)", function() {\r
- expect(5);\r
- var defaultText = 'Try them out:'\r
- var result = $('#first').prepend('<b>buga</b>');\r
- ok( result.text() == 'buga' + defaultText, 'Check if text prepending works' );\r
- ok( $('#select3').prepend('<option value="prependTest">Prepend Test</option>').find('option:first-child').attr('value') == 'prependTest', 'Prepending html options to select element');\r
- \r
- reset();\r
- expected = "Try them out:This link has class=\"blog\": Simon Willison's Weblog";\r
- $('#sap').prepend(document.getElementById('first'));\r
- ok( expected == $('#sap').text(), "Check for prepending of element" );\r
-\r
- reset();\r
- expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";\r
- $('#sap').prepend([document.getElementById('first'), document.getElementById('yahoo')]);\r
- ok( expected == $('#sap').text(), "Check for prepending of array of elements" );\r
- \r
- reset();\r
- expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";\r
- $('#sap').prepend($("#first, #yahoo"));\r
- ok( expected == $('#sap').text(), "Check for prepending of jQuery object" );\r
-});\r
-\r
-test("prependTo(String|Element|Array<Element>|jQuery)", function() {\r
- expect(5);\r
- var defaultText = 'Try them out:'\r
- $('<b>buga</b>').prependTo('#first');\r
- ok( $('#first').text() == 'buga' + defaultText, 'Check if text prepending works' );\r
- ok( $('<option value="prependTest">Prepend Test</option>').prependTo('#select3').parent().find('option:first-child').attr('value') == 'prependTest', 'Prepending html options to select element');\r
- \r
- reset();\r
- expected = "Try them out:This link has class=\"blog\": Simon Willison's Weblog";\r
- $(document.getElementById('first')).prependTo('#sap');\r
- ok( expected == $('#sap').text(), "Check for prepending of element" );\r
-\r
- reset();\r
- expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";\r
- $([document.getElementById('yahoo'), document.getElementById('first')]).prependTo('#sap');\r
- ok( expected == $('#sap').text(), "Check for prepending of array of elements" );\r
- \r
- reset();\r
- expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";\r
- $("#yahoo, #first").prependTo('#sap');\r
- ok( expected == $('#sap').text(), "Check for prepending of jQuery object" );\r
-});\r
-\r
-test("before(String|Element|Array<Element>|jQuery)", function() {\r
- expect(4);\r
- var expected = 'This is a normal link: bugaYahoo';\r
- $('#yahoo').before('<b>buga</b>');\r
- ok( expected == $('#en').text(), 'Insert String before' );\r
- \r
- reset();\r
- expected = "This is a normal link: Try them out:Yahoo";\r
- $('#yahoo').before(document.getElementById('first'));\r
- ok( expected == $('#en').text(), "Insert element before" );\r
- \r
- reset();\r
- expected = "This is a normal link: Try them out:diveintomarkYahoo";\r
- $('#yahoo').before([document.getElementById('first'), document.getElementById('mark')]);\r
- ok( expected == $('#en').text(), "Insert array of elements before" );\r
- \r
- reset();\r
- expected = "This is a normal link: Try them out:diveintomarkYahoo";\r
- $('#yahoo').before($("#first, #mark"));\r
- ok( expected == $('#en').text(), "Insert jQuery before" );\r
-});\r
-\r
-test("insertBefore(String|Element|Array<Element>|jQuery)", function() {\r
- expect(4);\r
- var expected = 'This is a normal link: bugaYahoo';\r
- $('<b>buga</b>').insertBefore('#yahoo');\r
- ok( expected == $('#en').text(), 'Insert String before' );\r
- \r
- reset();\r
- expected = "This is a normal link: Try them out:Yahoo";\r
- $(document.getElementById('first')).insertBefore('#yahoo');\r
- ok( expected == $('#en').text(), "Insert element before" );\r
- \r
- reset();\r
- expected = "This is a normal link: Try them out:diveintomarkYahoo";\r
- $([document.getElementById('first'), document.getElementById('mark')]).insertBefore('#yahoo');\r
- ok( expected == $('#en').text(), "Insert array of elements before" );\r
- \r
- reset();\r
- expected = "This is a normal link: Try them out:diveintomarkYahoo";\r
- $("#first, #mark").insertBefore('#yahoo');\r
- ok( expected == $('#en').text(), "Insert jQuery before" );\r
-});\r
-\r
-test("after(String|Element|Array<Element>|jQuery)", function() {\r
- expect(4);\r
- var expected = 'This is a normal link: Yahoobuga';\r
- $('#yahoo').after('<b>buga</b>');\r
- ok( expected == $('#en').text(), 'Insert String after' );\r
- \r
- reset();\r
- expected = "This is a normal link: YahooTry them out:";\r
- $('#yahoo').after(document.getElementById('first'));\r
- ok( expected == $('#en').text(), "Insert element after" );\r
-\r
- reset();\r
- expected = "This is a normal link: YahooTry them out:diveintomark";\r
- $('#yahoo').after([document.getElementById('first'), document.getElementById('mark')]);\r
- ok( expected == $('#en').text(), "Insert array of elements after" );\r
- \r
- reset();\r
- expected = "This is a normal link: YahooTry them out:diveintomark";\r
- $('#yahoo').after($("#first, #mark"));\r
- ok( expected == $('#en').text(), "Insert jQuery after" );\r
-});\r
-\r
-test("insertAfter(String|Element|Array<Element>|jQuery)", function() {\r
- expect(4);\r
- var expected = 'This is a normal link: Yahoobuga';\r
- $('<b>buga</b>').insertAfter('#yahoo');\r
- ok( expected == $('#en').text(), 'Insert String after' );\r
- \r
- reset();\r
- expected = "This is a normal link: YahooTry them out:";\r
- $(document.getElementById('first')).insertAfter('#yahoo');\r
- ok( expected == $('#en').text(), "Insert element after" );\r
-\r
- reset();\r
- expected = "This is a normal link: YahooTry them out:diveintomark";\r
- $([document.getElementById('mark'), document.getElementById('first')]).insertAfter('#yahoo');\r
- ok( expected == $('#en').text(), "Insert array of elements after" );\r
- \r
- reset();\r
- expected = "This is a normal link: YahooTry them out:diveintomark";\r
- $("#mark, #first").insertAfter('#yahoo');\r
- ok( expected == $('#en').text(), "Insert jQuery after" );\r
-});\r
-\r
-test("end()", function() {\r
- expect(3);\r
- ok( 'Yahoo' == $('#yahoo').parent().end().text(), 'Check for end' );\r
- ok( $('#yahoo').end(), 'Check for end with nothing to end' );\r
- \r
- var x = $('#yahoo');\r
- x.parent();\r
- ok( 'Yahoo' == $('#yahoo').text(), 'Check for non-destructive behaviour' );\r
-});\r
-\r
+ reset();
+ //stop();
+ $('#check1').click(function() {
+ var checkbox = this;
+ ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );
+ $(checkbox).wrap( '<div id="c1" style="display:none;"></div>' );
+ ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );
+ // use a fade in to check state after this event handler has finished
+ /*setTimeout(function() {
+ ok( !checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );
+ start();
+ }, 100);*/
+ }).click();
+});
+
+test("append(String|Element|Array<Element>|jQuery)", function() {
+ expect(17);
+ var defaultText = 'Try them out:'
+ var result = $('#first').append('<b>buga</b>');
+ ok( result.text() == defaultText + 'buga', 'Check if text appending works' );
+ ok( $('#select3').append('<option value="appendTest">Append Test</option>').find('option:last-child').attr('value') == 'appendTest', 'Appending html options to select element');
+
+ reset();
+ var expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:";
+ $('#sap').append(document.getElementById('first'));
+ ok( expected == $('#sap').text(), "Check for appending of element" );
+
+ reset();
+ expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";
+ $('#sap').append([document.getElementById('first'), document.getElementById('yahoo')]);
+ ok( expected == $('#sap').text(), "Check for appending of array of elements" );
+
+ reset();
+ expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";
+ $('#sap').append($("#first, #yahoo"));
+ ok( expected == $('#sap').text(), "Check for appending of jQuery object" );
+
+ reset();
+ $("#sap").append( 5 );
+ ok( $("#sap")[0].innerHTML.match( /5$/ ), "Check for appending a number" );
+
+ reset();
+ $("#sap").append( " text with spaces " );
+ ok( $("#sap")[0].innerHTML.match(/ text with spaces $/), "Check for appending text with spaces" );
+
+ reset();
+ ok( $("#sap").append([]), "Check for appending an empty array." );
+ ok( $("#sap").append(""), "Check for appending an empty string." );
+ ok( $("#sap").append(document.getElementsByTagName("foo")), "Check for appending an empty nodelist." );
+
+ 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" );
+
+ reset();
+ $('<fieldset/>').appendTo('#form').append('<legend id="legend">test</legend>');
+ t( 'Append legend', '#legend', ['legend'] );
+
+ reset();
+ $('#select1').append('<OPTION>Test</OPTION>');
+ ok( $('#select1 option:last').text() == "Test", "Appending <OPTION> (all caps)" );
+
+ $('#table').append('<colgroup></colgroup>');
+ ok( $('#table colgroup').length, "Append colgroup" );
+
+ $('#table colgroup').append('<col/>');
+ ok( $('#table colgroup col').length, "Append col" );
+
+ reset();
+ $('form:last')
+ .append('<select id="appendSelect1"></select>')
+ .append('<select id="appendSelect2"><option>Test</option></select>');
+
+ t( "Append Select", "#appendSelect1, #appendSelect2", ["appendSelect1", "appendSelect2"] );
+});
+
+test("appendTo(String|Element|Array<Element>|jQuery)", function() {
+ expect(6);
+ var defaultText = 'Try them out:'
+ $('<b>buga</b>').appendTo('#first');
+ ok( $("#first").text() == defaultText + 'buga', 'Check if text appending works' );
+ ok( $('<option value="appendTest">Append Test</option>').appendTo('#select3').parent().find('option:last-child').attr('value') == 'appendTest', 'Appending html options to select element');
+
+ reset();
+ var expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:";
+ $(document.getElementById('first')).appendTo('#sap');
+ ok( expected == $('#sap').text(), "Check for appending of element" );
+
+ reset();
+ expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";
+ $([document.getElementById('first'), document.getElementById('yahoo')]).appendTo('#sap');
+ ok( expected == $('#sap').text(), "Check for appending of array of elements" );
+
+ reset();
+ expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";
+ $("#first, #yahoo").appendTo('#sap');
+ ok( expected == $('#sap').text(), "Check for appending of jQuery object" );
+
+ reset();
+ $('#select1').appendTo('#foo');
+ t( 'Append select', '#foo select', ['select1'] );
+});
+
+test("prepend(String|Element|Array<Element>|jQuery)", function() {
+ expect(5);
+ var defaultText = 'Try them out:'
+ var result = $('#first').prepend('<b>buga</b>');
+ ok( result.text() == 'buga' + defaultText, 'Check if text prepending works' );
+ ok( $('#select3').prepend('<option value="prependTest">Prepend Test</option>').find('option:first-child').attr('value') == 'prependTest', 'Prepending html options to select element');
+
+ reset();
+ var expected = "Try them out:This link has class=\"blog\": Simon Willison's Weblog";
+ $('#sap').prepend(document.getElementById('first'));
+ ok( expected == $('#sap').text(), "Check for prepending of element" );
+
+ reset();
+ expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";
+ $('#sap').prepend([document.getElementById('first'), document.getElementById('yahoo')]);
+ ok( expected == $('#sap').text(), "Check for prepending of array of elements" );
+
+ reset();
+ expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";
+ $('#sap').prepend($("#first, #yahoo"));
+ ok( expected == $('#sap').text(), "Check for prepending of jQuery object" );
+});
+
+test("prependTo(String|Element|Array<Element>|jQuery)", function() {
+ expect(6);
+ var defaultText = 'Try them out:'
+ $('<b>buga</b>').prependTo('#first');
+ ok( $('#first').text() == 'buga' + defaultText, 'Check if text prepending works' );
+ ok( $('<option value="prependTest">Prepend Test</option>').prependTo('#select3').parent().find('option:first-child').attr('value') == 'prependTest', 'Prepending html options to select element');
+
+ reset();
+ var expected = "Try them out:This link has class=\"blog\": Simon Willison's Weblog";
+ $(document.getElementById('first')).prependTo('#sap');
+ ok( expected == $('#sap').text(), "Check for prepending of element" );
+
+ reset();
+ expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";
+ $([document.getElementById('yahoo'), document.getElementById('first')]).prependTo('#sap');
+ ok( expected == $('#sap').text(), "Check for prepending of array of elements" );
+
+ reset();
+ expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";
+ $("#yahoo, #first").prependTo('#sap');
+ ok( expected == $('#sap').text(), "Check for prepending of jQuery object" );
+
+ reset();
+ $('<select id="prependSelect1"></select>').prependTo('form:last');
+ $('<select id="prependSelect2"><option>Test</option></select>').prependTo('form:last');
+
+ t( "Prepend Select", "#prependSelect1, #prependSelect2", ["prependSelect1", "prependSelect2"] );
+});
+
+test("before(String|Element|Array<Element>|jQuery)", function() {
+ expect(4);
+ var expected = 'This is a normal link: bugaYahoo';
+ $('#yahoo').before('<b>buga</b>');
+ ok( expected == $('#en').text(), 'Insert String before' );
+
+ reset();
+ expected = "This is a normal link: Try them out:Yahoo";
+ $('#yahoo').before(document.getElementById('first'));
+ ok( expected == $('#en').text(), "Insert element before" );
+
+ reset();
+ expected = "This is a normal link: Try them out:diveintomarkYahoo";
+ $('#yahoo').before([document.getElementById('first'), document.getElementById('mark')]);
+ ok( expected == $('#en').text(), "Insert array of elements before" );
+
+ reset();
+ expected = "This is a normal link: Try them out:diveintomarkYahoo";
+ $('#yahoo').before($("#first, #mark"));
+ ok( expected == $('#en').text(), "Insert jQuery before" );
+});
+
+test("insertBefore(String|Element|Array<Element>|jQuery)", function() {
+ expect(4);
+ var expected = 'This is a normal link: bugaYahoo';
+ $('<b>buga</b>').insertBefore('#yahoo');
+ ok( expected == $('#en').text(), 'Insert String before' );
+
+ reset();
+ expected = "This is a normal link: Try them out:Yahoo";
+ $(document.getElementById('first')).insertBefore('#yahoo');
+ ok( expected == $('#en').text(), "Insert element before" );
+
+ reset();
+ expected = "This is a normal link: Try them out:diveintomarkYahoo";
+ $([document.getElementById('first'), document.getElementById('mark')]).insertBefore('#yahoo');
+ ok( expected == $('#en').text(), "Insert array of elements before" );
+
+ reset();
+ expected = "This is a normal link: Try them out:diveintomarkYahoo";
+ $("#first, #mark").insertBefore('#yahoo');
+ ok( expected == $('#en').text(), "Insert jQuery before" );
+});
+
+test("after(String|Element|Array<Element>|jQuery)", function() {
+ expect(4);
+ var expected = 'This is a normal link: Yahoobuga';
+ $('#yahoo').after('<b>buga</b>');
+ ok( expected == $('#en').text(), 'Insert String after' );
+
+ reset();
+ expected = "This is a normal link: YahooTry them out:";
+ $('#yahoo').after(document.getElementById('first'));
+ ok( expected == $('#en').text(), "Insert element after" );
+
+ reset();
+ expected = "This is a normal link: YahooTry them out:diveintomark";
+ $('#yahoo').after([document.getElementById('first'), document.getElementById('mark')]);
+ ok( expected == $('#en').text(), "Insert array of elements after" );
+
+ reset();
+ expected = "This is a normal link: YahooTry them out:diveintomark";
+ $('#yahoo').after($("#first, #mark"));
+ ok( expected == $('#en').text(), "Insert jQuery after" );
+});
+
+test("insertAfter(String|Element|Array<Element>|jQuery)", function() {
+ expect(4);
+ var expected = 'This is a normal link: Yahoobuga';
+ $('<b>buga</b>').insertAfter('#yahoo');
+ ok( expected == $('#en').text(), 'Insert String after' );
+
+ reset();
+ expected = "This is a normal link: YahooTry them out:";
+ $(document.getElementById('first')).insertAfter('#yahoo');
+ ok( expected == $('#en').text(), "Insert element after" );
+
+ reset();
+ expected = "This is a normal link: YahooTry them out:diveintomark";
+ $([document.getElementById('mark'), document.getElementById('first')]).insertAfter('#yahoo');
+ ok( expected == $('#en').text(), "Insert array of elements after" );
+
+ reset();
+ expected = "This is a normal link: YahooTry them out:diveintomark";
+ $("#mark, #first").insertAfter('#yahoo');
+ ok( expected == $('#en').text(), "Insert jQuery after" );
+});
+
+test("end()", function() {
+ expect(3);
+ ok( 'Yahoo' == $('#yahoo').parent().end().text(), 'Check for end' );
+ ok( $('#yahoo').end(), 'Check for end with nothing to end' );
+
+ var x = $('#yahoo');
+ x.parent();
+ ok( 'Yahoo' == $('#yahoo').text(), 'Check for non-destructive behaviour' );
+});
+