1 module("manipulation");
3 test("text()", function() {
5 var expected = "This link has class=\"blog\": Simon Willison's Weblog";
6 equals( jQuery('#sap').text(), expected, 'Check for merged text of more then one element.' );
9 test("wrap(String|Element)", function() {
11 var defaultText = 'Try them out:'
12 var result = jQuery('#first').wrap('<div class="red"><span></span></div>').text();
13 equals( defaultText, result, 'Check for wrapping of on-the-fly html' );
14 ok( jQuery('#first').parent().parent().is('.red'), 'Check if wrapper has class "red"' );
17 var defaultText = 'Try them out:'
18 var result = jQuery('#first').wrap(document.getElementById('empty')).parent();
19 ok( result.is('ol'), 'Check for element wrapping' );
20 equals( result.text(), defaultText, 'Check for element wrapping' );
23 jQuery('#check1').click(function() {
25 ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );
26 jQuery(checkbox).wrap( '<div id="c1" style="display:none;"></div>' );
27 ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );
30 // using contents will get comments regular, text, and comment nodes
31 var j = jQuery("#nonnodes").contents();
33 equals( jQuery("#nonnodes > i").length, 3, "Check node,textnode,comment wraps ok" );
34 equals( jQuery("#nonnodes > i").text(), j.text() + j[1].nodeValue, "Check node,textnode,comment wraps doesn't hurt text" );
36 // Try wrapping a disconnected node
37 j = jQuery("<label/>").wrap("<li/>");
38 equals( j[0].nodeName.toUpperCase(), "LABEL", "Element is a label" );
39 equals( j[0].parentNode.nodeName.toUpperCase(), "LI", "Element has been wrapped" );
42 test("wrapAll(String|Element)", function() {
44 var prev = jQuery("#firstp")[0].previousSibling;
45 var p = jQuery("#firstp,#first")[0].parentNode;
46 var result = jQuery('#firstp,#first').wrapAll('<div class="red"><div id="tmp"></div></div>');
47 equals( result.parent().length, 1, 'Check for wrapping of on-the-fly html' );
48 ok( jQuery('#first').parent().parent().is('.red'), 'Check if wrapper has class "red"' );
49 ok( jQuery('#firstp').parent().parent().is('.red'), 'Check if wrapper has class "red"' );
50 equals( jQuery("#first").parent().parent()[0].previousSibling, prev, "Correct Previous Sibling" );
51 equals( jQuery("#first").parent().parent()[0].parentNode, p, "Correct Parent" );
54 var prev = jQuery("#firstp")[0].previousSibling;
55 var p = jQuery("#first")[0].parentNode;
56 var result = jQuery('#firstp,#first').wrapAll(document.getElementById('empty'));
57 equals( jQuery("#first").parent()[0], jQuery("#firstp").parent()[0], "Same Parent" );
58 equals( jQuery("#first").parent()[0].previousSibling, prev, "Correct Previous Sibling" );
59 equals( jQuery("#first").parent()[0].parentNode, p, "Correct Parent" );
62 test("wrapInner(String|Element)", function() {
64 var num = jQuery("#first").children().length;
65 var result = jQuery('#first').wrapInner('<div class="red"><div id="tmp"></div></div>');
66 equals( jQuery("#first").children().length, 1, "Only one child" );
67 ok( jQuery("#first").children().is(".red"), "Verify Right Element" );
68 equals( jQuery("#first").children().children().children().length, num, "Verify Elements Intact" );
71 var num = jQuery("#first").children().length;
72 var result = jQuery('#first').wrapInner(document.getElementById('empty'));
73 equals( jQuery("#first").children().length, 1, "Only one child" );
74 ok( jQuery("#first").children().is("#empty"), "Verify Right Element" );
75 equals( jQuery("#first").children().children().length, num, "Verify Elements Intact" );
78 test("append(String|Element|Array<Element>|jQuery)", function() {
80 var defaultText = 'Try them out:'
81 var result = jQuery('#first').append('<b>buga</b>');
82 equals( result.text(), defaultText + 'buga', 'Check if text appending works' );
83 equals( jQuery('#select3').append('<option value="appendTest">Append Test</option>').find('option:last-child').attr('value'), 'appendTest', 'Appending html options to select element');
86 var expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:";
87 jQuery('#sap').append(document.getElementById('first'));
88 equals( expected, jQuery('#sap').text(), "Check for appending of element" );
91 expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";
92 jQuery('#sap').append([document.getElementById('first'), document.getElementById('yahoo')]);
93 equals( expected, jQuery('#sap').text(), "Check for appending of array of elements" );
96 expected = "This link has class=\"blog\": Simon Willison's WeblogYahooTry them out:";
97 jQuery('#sap').append(jQuery("#first, #yahoo"));
98 equals( expected, jQuery('#sap').text(), "Check for appending of jQuery object" );
101 jQuery("#sap").append( 5 );
102 ok( jQuery("#sap")[0].innerHTML.match( /5$/ ), "Check for appending a number" );
105 jQuery("#sap").append( " text with spaces " );
106 ok( jQuery("#sap")[0].innerHTML.match(/ text with spaces $/), "Check for appending text with spaces" );
109 ok( jQuery("#sap").append([]), "Check for appending an empty array." );
110 ok( jQuery("#sap").append(""), "Check for appending an empty string." );
111 ok( jQuery("#sap").append(document.getElementsByTagName("foo")), "Check for appending an empty nodelist." );
114 jQuery("#sap").append(document.getElementById('form'));
115 equals( jQuery("#sap>form").size(), 1, "Check for appending a form" ); // Bug #910
120 jQuery( jQuery("#iframe")[0].contentWindow.document.body ).append("<div>test</div>");
125 ok( pass, "Test for appending a DOM node to the contents of an IFrame" );
128 jQuery('<fieldset/>').appendTo('#form').append('<legend id="legend">test</legend>');
129 t( 'Append legend', '#legend', ['legend'] );
132 jQuery('#select1').append('<OPTION>Test</OPTION>');
133 equals( jQuery('#select1 option:last').text(), "Test", "Appending <OPTION> (all caps)" );
135 jQuery('#table').append('<colgroup></colgroup>');
136 ok( jQuery('#table colgroup').length, "Append colgroup" );
138 jQuery('#table colgroup').append('<col/>');
139 ok( jQuery('#table colgroup col').length, "Append col" );
142 jQuery('#table').append('<caption></caption>');
143 ok( jQuery('#table caption').length, "Append caption" );
147 .append('<select id="appendSelect1"></select>')
148 .append('<select id="appendSelect2"><option>Test</option></select>');
150 t( "Append Select", "#appendSelect1, #appendSelect2", ["appendSelect1", "appendSelect2"] );
152 // using contents will get comments regular, text, and comment nodes
153 var j = jQuery("#nonnodes").contents();
154 var d = jQuery("<div/>").appendTo("#nonnodes").append(j);
155 equals( jQuery("#nonnodes").length, 1, "Check node,textnode,comment append moved leaving just the div" );
156 ok( d.contents().length >= 2, "Check node,textnode,comment append works" );
157 d.contents().appendTo("#nonnodes");
159 ok( jQuery("#nonnodes").contents().length >= 2, "Check node,textnode,comment append cleanup worked" );
162 test("appendTo(String|Element|Array<Element>|jQuery)", function() {
164 var defaultText = 'Try them out:'
165 jQuery('<b>buga</b>').appendTo('#first');
166 equals( jQuery("#first").text(), defaultText + 'buga', 'Check if text appending works' );
167 equals( jQuery('<option value="appendTest">Append Test</option>').appendTo('#select3').parent().find('option:last-child').attr('value'), 'appendTest', 'Appending html options to select element');
170 var expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:";
171 jQuery(document.getElementById('first')).appendTo('#sap');
172 equals( expected, jQuery('#sap').text(), "Check for appending of element" );
175 expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";
176 jQuery([document.getElementById('first'), document.getElementById('yahoo')]).appendTo('#sap');
177 equals( expected, jQuery('#sap').text(), "Check for appending of array of elements" );
180 ok( jQuery(document.createElement("script")).appendTo("body").length, "Make sure a disconnected script can be appended." );
183 expected = "This link has class=\"blog\": Simon Willison's WeblogYahooTry them out:";
184 jQuery("#first, #yahoo").appendTo('#sap');
185 equals( expected, jQuery('#sap').text(), "Check for appending of jQuery object" );
188 jQuery('#select1').appendTo('#foo');
189 t( 'Append select', '#foo select', ['select1'] );
192 var div = jQuery("<div/>").click(function(){
193 ok(true, "Running a cloned click.");
195 div.appendTo("#main, #moretests");
197 jQuery("#main div:last").click();
198 jQuery("#moretests div:last").click();
201 var div = jQuery("<div/>").appendTo("#main, #moretests");
203 equals( div.length, 2, "appendTo returns the inserted elements" );
205 div.addClass("test");
207 ok( jQuery("#main div:last").hasClass("test"), "appendTo element was modified after the insertion" );
208 ok( jQuery("#moretests div:last").hasClass("test"), "appendTo element was modified after the insertion" );
213 test("prepend(String|Element|Array<Element>|jQuery)", function() {
215 var defaultText = 'Try them out:'
216 var result = jQuery('#first').prepend('<b>buga</b>');
217 equals( result.text(), 'buga' + defaultText, 'Check if text prepending works' );
218 equals( jQuery('#select3').prepend('<option value="prependTest">Prepend Test</option>').find('option:first-child').attr('value'), 'prependTest', 'Prepending html options to select element');
221 var expected = "Try them out:This link has class=\"blog\": Simon Willison's Weblog";
222 jQuery('#sap').prepend(document.getElementById('first'));
223 equals( expected, jQuery('#sap').text(), "Check for prepending of element" );
226 expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";
227 jQuery('#sap').prepend([document.getElementById('first'), document.getElementById('yahoo')]);
228 equals( expected, jQuery('#sap').text(), "Check for prepending of array of elements" );
231 expected = "YahooTry them out:This link has class=\"blog\": Simon Willison's Weblog";
232 jQuery('#sap').prepend(jQuery("#first, #yahoo"));
233 equals( expected, jQuery('#sap').text(), "Check for prepending of jQuery object" );
236 test("prependTo(String|Element|Array<Element>|jQuery)", function() {
238 var defaultText = 'Try them out:'
239 jQuery('<b>buga</b>').prependTo('#first');
240 equals( jQuery('#first').text(), 'buga' + defaultText, 'Check if text prepending works' );
241 equals( jQuery('<option value="prependTest">Prepend Test</option>').prependTo('#select3').parent().find('option:first-child').attr('value'), 'prependTest', 'Prepending html options to select element');
244 var expected = "Try them out:This link has class=\"blog\": Simon Willison's Weblog";
245 jQuery(document.getElementById('first')).prependTo('#sap');
246 equals( expected, jQuery('#sap').text(), "Check for prepending of element" );
249 expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";
250 jQuery([document.getElementById('first'), document.getElementById('yahoo')]).prependTo('#sap');
251 equals( expected, jQuery('#sap').text(), "Check for prepending of array of elements" );
254 expected = "YahooTry them out:This link has class=\"blog\": Simon Willison's Weblog";
255 jQuery("#first, #yahoo").prependTo('#sap');
256 equals( expected, jQuery('#sap').text(), "Check for prepending of jQuery object" );
259 jQuery('<select id="prependSelect1"></select>').prependTo('form:last');
260 jQuery('<select id="prependSelect2"><option>Test</option></select>').prependTo('form:last');
262 t( "Prepend Select", "#prependSelect2, #prependSelect1", ["prependSelect2", "prependSelect1"] );
265 test("before(String|Element|Array<Element>|jQuery)", function() {
267 var expected = 'This is a normal link: bugaYahoo';
268 jQuery('#yahoo').before('<b>buga</b>');
269 equals( expected, jQuery('#en').text(), 'Insert String before' );
272 expected = "This is a normal link: Try them out:Yahoo";
273 jQuery('#yahoo').before(document.getElementById('first'));
274 equals( expected, jQuery('#en').text(), "Insert element before" );
277 expected = "This is a normal link: Try them out:diveintomarkYahoo";
278 jQuery('#yahoo').before([document.getElementById('first'), document.getElementById('mark')]);
279 equals( expected, jQuery('#en').text(), "Insert array of elements before" );
282 expected = "This is a normal link: diveintomarkTry them out:Yahoo";
283 jQuery('#yahoo').before(jQuery("#first, #mark"));
284 equals( expected, jQuery('#en').text(), "Insert jQuery before" );
287 test("insertBefore(String|Element|Array<Element>|jQuery)", function() {
289 var expected = 'This is a normal link: bugaYahoo';
290 jQuery('<b>buga</b>').insertBefore('#yahoo');
291 equals( expected, jQuery('#en').text(), 'Insert String before' );
294 expected = "This is a normal link: Try them out:Yahoo";
295 jQuery(document.getElementById('first')).insertBefore('#yahoo');
296 equals( expected, jQuery('#en').text(), "Insert element before" );
299 expected = "This is a normal link: Try them out:diveintomarkYahoo";
300 jQuery([document.getElementById('first'), document.getElementById('mark')]).insertBefore('#yahoo');
301 equals( expected, jQuery('#en').text(), "Insert array of elements before" );
304 expected = "This is a normal link: diveintomarkTry them out:Yahoo";
305 jQuery("#first, #mark").insertBefore('#yahoo');
306 equals( expected, jQuery('#en').text(), "Insert jQuery before" );
309 test("after(String|Element|Array<Element>|jQuery)", function() {
311 var expected = 'This is a normal link: Yahoobuga';
312 jQuery('#yahoo').after('<b>buga</b>');
313 equals( expected, jQuery('#en').text(), 'Insert String after' );
316 expected = "This is a normal link: YahooTry them out:";
317 jQuery('#yahoo').after(document.getElementById('first'));
318 equals( expected, jQuery('#en').text(), "Insert element after" );
321 expected = "This is a normal link: YahooTry them out:diveintomark";
322 jQuery('#yahoo').after([document.getElementById('first'), document.getElementById('mark')]);
323 equals( expected, jQuery('#en').text(), "Insert array of elements after" );
326 expected = "This is a normal link: YahoodiveintomarkTry them out:";
327 jQuery('#yahoo').after(jQuery("#first, #mark"));
328 equals( expected, jQuery('#en').text(), "Insert jQuery after" );
331 test("insertAfter(String|Element|Array<Element>|jQuery)", function() {
333 var expected = 'This is a normal link: Yahoobuga';
334 jQuery('<b>buga</b>').insertAfter('#yahoo');
335 equals( expected, jQuery('#en').text(), 'Insert String after' );
338 expected = "This is a normal link: YahooTry them out:";
339 jQuery(document.getElementById('first')).insertAfter('#yahoo');
340 equals( expected, jQuery('#en').text(), "Insert element after" );
343 expected = "This is a normal link: YahooTry them out:diveintomark";
344 jQuery([document.getElementById('first'), document.getElementById('mark')]).insertAfter('#yahoo');
345 equals( expected, jQuery('#en').text(), "Insert array of elements after" );
348 expected = "This is a normal link: YahoodiveintomarkTry them out:";
349 jQuery("#first, #mark").insertAfter('#yahoo');
350 equals( expected, jQuery('#en').text(), "Insert jQuery after" );
353 test("replaceWith(String|Element|Array<Element>|jQuery)", function() {
355 jQuery('#yahoo').replaceWith('<b id="replace">buga</b>');
356 ok( jQuery("#replace")[0], 'Replace element with string' );
357 ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after string' );
360 jQuery('#yahoo').replaceWith(document.getElementById('first'));
361 ok( jQuery("#first")[0], 'Replace element with element' );
362 ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after element' );
365 jQuery('#yahoo').replaceWith([document.getElementById('first'), document.getElementById('mark')]);
366 ok( jQuery("#first")[0], 'Replace element with array of elements' );
367 ok( jQuery("#mark")[0], 'Replace element with array of elements' );
368 ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after array of elements' );
371 jQuery('#yahoo').replaceWith(jQuery("#first, #mark"));
372 ok( jQuery("#first")[0], 'Replace element with set of elements' );
373 ok( jQuery("#mark")[0], 'Replace element with set of elements' );
374 ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after set of elements' );
377 test("replaceAll(String|Element|Array<Element>|jQuery)", function() {
379 jQuery('<b id="replace">buga</b>').replaceAll("#yahoo");
380 ok( jQuery("#replace")[0], 'Replace element with string' );
381 ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after string' );
384 jQuery(document.getElementById('first')).replaceAll("#yahoo");
385 ok( jQuery("#first")[0], 'Replace element with element' );
386 ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after element' );
389 jQuery([document.getElementById('first'), document.getElementById('mark')]).replaceAll("#yahoo");
390 ok( jQuery("#first")[0], 'Replace element with array of elements' );
391 ok( jQuery("#mark")[0], 'Replace element with array of elements' );
392 ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after array of elements' );
395 jQuery("#first, #mark").replaceAll("#yahoo");
396 ok( jQuery("#first")[0], 'Replace element with set of elements' );
397 ok( jQuery("#mark")[0], 'Replace element with set of elements' );
398 ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after set of elements' );
401 test("clone()", function() {
403 equals( 'This is a normal link: Yahoo', jQuery('#en').text(), 'Assert text for #en' );
404 var clone = jQuery('#yahoo').clone();
405 equals( 'Try them out:Yahoo', jQuery('#first').append(clone).text(), 'Check for clone' );
406 equals( 'This is a normal link: Yahoo', jQuery('#en').text(), 'Reassert text for #en' );
409 "<table/>", "<tr/>", "<td/>", "<div/>",
410 "<button/>", "<ul/>", "<ol/>", "<li/>",
411 "<input type='checkbox' />", "<select/>", "<option/>", "<textarea/>",
412 "<tbody/>", "<thead/>", "<tfoot/>", "<iframe/>"
414 for (var i = 0; i < cloneTags.length; i++) {
415 var j = jQuery(cloneTags[i]);
416 equals( j[0].tagName, j.clone()[0].tagName, 'Clone a <' + cloneTags[i].substring(1));
419 // using contents will get comments regular, text, and comment nodes
420 var cl = jQuery("#nonnodes").contents().clone();
421 ok( cl.length >= 2, "Check node,textnode,comment clone works (some browsers delete comments on clone)" );
423 var div = jQuery("<div><ul><li>test</li></ul></div>").click(function(){
424 ok( true, "Bound event still exists." );
427 div = div.clone(true).clone(true);
428 equals( div.length, 1, "One element cloned" );
429 equals( div[0].nodeName.toUpperCase(), "DIV", "DIV element cloned" );
430 div.trigger("click");
432 div = jQuery("<div/>").append([ document.createElement("table"), document.createElement("table") ]);
433 div.find("table").click(function(){
434 ok( true, "Bound event still exists." );
437 div = div.clone(true);
438 equals( div.length, 1, "One element cloned" );
439 equals( div[0].nodeName.toUpperCase(), "DIV", "DIV element cloned" );
440 div.find("table:last").trigger("click");
442 div = jQuery("<div/>").html('<object height="355" width="425"> <param name="movie" value="http://www.youtube.com/v/JikaHBDoV3k&hl=en"> <param name="wmode" value="transparent"> </object>');
444 div = div.clone(true);
445 equals( div.length, 1, "One element cloned" );
446 equals( div[0].nodeName.toUpperCase(), "DIV", "DIV element cloned" );
450 test("clone() on XML nodes", function() {
453 jQuery.get("data/dashboard.xml", function (xml) {
454 var root = jQuery(xml.documentElement).clone();
455 var origTab = jQuery("tab", xml).eq(0);
456 var cloneTab = jQuery("tab", root).eq(0);
457 origTab.text("origval");
458 cloneTab.text("cloneval");
459 equals(origTab.text(), "origval", "Check original XML node was correctly set");
460 equals(cloneTab.text(), "cloneval", "Check cloned XML node was correctly set");
466 test("val()", function() {
469 equals( jQuery("#text1").val(), "Test", "Check for value of input element" );
470 // ticket #1714 this caused a JS error in IE
471 equals( jQuery("#first").val(), "", "Check a paragraph element to see if it has a value" );
472 ok( jQuery([]).val() === undefined, "Check an empty jQuery object will return undefined from val" );
474 equals( jQuery('#select2').val(), '3', 'Call val() on a single="single" select' );
476 isSet( jQuery('#select3').val(), ['1', '2'], 'Call val() on a multiple="multiple" select' );
478 equals( jQuery('#option3c').val(), '2', 'Call val() on a option element with value' );
480 equals( jQuery('#option3a').val(), '', 'Call val() on a option element with empty value' );
482 equals( jQuery('#option3e').val(), 'no value', 'Call val() on a option element with no value attribute' );
486 test("val(String/Number)", function() {
488 document.getElementById('text1').value = "bla";
489 equals( jQuery("#text1").val(), "bla", "Check for modified value of input element" );
491 jQuery("#text1").val('test');
492 equals( document.getElementById('text1').value, "test", "Check for modified (via val(String)) value of input element" );
494 jQuery("#text1").val(67);
495 equals( document.getElementById('text1').value, "67", "Check for modified (via val(Number)) value of input element" );
497 jQuery("#select1").val("3");
498 equals( jQuery("#select1").val(), "3", "Check for modified (via val(String)) value of select element" );
500 jQuery("#select1").val(2);
501 equals( jQuery("#select1").val(), "2", "Check for modified (via val(Number)) value of select element" );
503 // using contents will get comments regular, text, and comment nodes
504 var j = jQuery("#nonnodes").contents();
506 equals( j.val(), "asdf", "Check node,textnode,comment with val()" );
507 j.removeAttr("value");
510 test("html(String)", function() {
513 jQuery.scriptorder = 0;
515 var div = jQuery("#main > div");
516 div.html("<b>test</b>");
518 for ( var i = 0; i < div.size(); i++ ) {
519 if ( div.get(i).childNodes.length != 1 ) pass = false;
521 ok( pass, "Set HTML" );
524 // using contents will get comments regular, text, and comment nodes
525 var j = jQuery("#nonnodes").contents();
526 j.html("<b>bold</b>");
528 // this is needed, or the expando added by jQuery unique will yield a different html
529 j.find('b').removeData();
530 equals( j.html().replace(/ xmlns="[^"]+"/g, "").toLowerCase(), "<b>bold</b>", "Check node,textnode,comment with html()" );
532 jQuery("#main").html("<select/>");
533 jQuery("#main select").html("<option>O1</option><option selected='selected'>O2</option><option>O3</option>");
534 equals( jQuery("#main select").val(), "O2", "Selected option correct" );
536 var $div = jQuery('<div />');
537 equals( $div.html( 5 ).html(), '5', 'Setting a number as html' );
538 equals( $div.html( 0 ).html(), '0', 'Setting a zero as html' );
542 jQuery("#main").html('<script type="something/else">ok( false, "Non-script evaluated." );</script><script type="text/javascript">ok( true, "text/javascript is evaluated." );</script><script>ok( true, "No type is evaluated." );</script><div><script type="text/javascript">ok( true, "Inner text/javascript is evaluated." );</script><script>ok( true, "Inner No type is evaluated." );</script><script type="something/else">ok( false, "Non-script evaluated." );</script></div>');
546 jQuery("#main").html('<script type="text/javascript">ok( true, "jQuery().html().evalScripts() Evals Scripts Twice in Firefox, see #975" );</script>');
548 jQuery("#main").html('foo <form><script type="text/javascript">ok( true, "jQuery().html().evalScripts() Evals Scripts Twice in Firefox, see #975" );</script></form>');
550 // it was decided that waiting to execute ALL scripts makes sense since nested ones have to wait anyway so this test case is changed, see #1959
551 jQuery("#main").html("<script>equals(jQuery.scriptorder++, 0, 'Script is executed in order');equals(jQuery('#scriptorder').length, 1,'Execute after html (even though appears before)')<\/script><span id='scriptorder'><script>equals(jQuery.scriptorder++, 1, 'Script (nested) is executed in order');equals(jQuery('#scriptorder').length, 1,'Execute after html')<\/script></span><script>equals(jQuery.scriptorder++, 2, 'Script (unnested) is executed in order');equals(jQuery('#scriptorder').length, 1,'Execute after html')<\/script>");
553 setTimeout( start, 100 );
556 test("text(String)", function() {
558 equals( jQuery("#foo").text("<div><b>Hello</b> cruel world!</div>")[0].innerHTML.replace(/>/g, ">"), "<div><b>Hello</b> cruel world!</div>", "Check escaped text" );
560 // using contents will get comments regular, text, and comment nodes
561 var j = jQuery("#nonnodes").contents();
563 equals( jQuery(j[0]).text(), "hi!", "Check node,textnode,comment with text()" );
564 equals( j[1].nodeValue, " there ", "Check node,textnode,comment with text()" );
565 equals( j[2].nodeType, 8, "Check node,textnode,comment with text()" );
568 test("remove()", function() {
570 jQuery("#ap").children().remove();
571 ok( jQuery("#ap").text().length > 10, "Check text is not removed" );
572 equals( jQuery("#ap").children().length, 0, "Check remove" );
575 jQuery("#ap").children().remove("a");
576 ok( jQuery("#ap").text().length > 10, "Check text is not removed" );
577 equals( jQuery("#ap").children().length, 1, "Check filtered remove" );
579 jQuery("#ap").children().remove("a, code");
580 equals( jQuery("#ap").children().length, 0, "Check multi-filtered remove" );
582 // using contents will get comments regular, text, and comment nodes
583 equals( jQuery("#nonnodes").contents().length, 3, "Check node,textnode,comment remove works" );
584 jQuery("#nonnodes").contents().remove();
585 equals( jQuery("#nonnodes").contents().length, 0, "Check node,textnode,comment remove works" );
588 test("empty()", function() {
590 equals( jQuery("#ap").children().empty().text().length, 0, "Check text is removed" );
591 equals( jQuery("#ap").children().length, 4, "Check elements are not removed" );
593 // using contents will get comments regular, text, and comment nodes
594 var j = jQuery("#nonnodes").contents();
596 equals( j.html(), "", "Check node,textnode,comment empty works" );