github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

jquery / jquery

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 1,336
    • 121
  • Source
  • Commits
  • Network (121)
  • Graphs
  • Tree: cc1a348
  • Branches (3)
    • master
    • mobile
    • omgrequire
  • Tags (39)
    • 1.4rc1
    • 1.4a2
    • 1.4a1
    • 1.4
    • 1.3rc1
    • 1.3b2
    • 1.3b1
    • 1.3.2
    • 1.3.1rc1
    • 1.3.1
    • 1.3
    • 1.2.6
    • 1.2.5
    • 1.2.4b
    • 1.2.4a
    • 1.2.4
    • 1.2.3b
    • 1.2.3a
    • 1.2.3
    • 1.2.2b2
    • 1.2.2b
    • 1.2.2
    • 1.2.1
    • 1.2
    • 1.1b
    • 1.1a
    • 1.1.4
    • 1.1.3a
    • 1.1.3.1
    • 1.1.3
    • 1.1.2
    • 1.1.1
    • 1.1
    • 1.0a
    • 1.0.4
    • 1.0.3
    • 1.0.2
    • 1.0.1
    • 1.0
  • Comments
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

jQuery JavaScript Library — Read more

or cancel

http://jquery.com/

or cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Added some .text(Function) tests.
jeresig (author)
Thu Jan 07 08:51:48 -0800 2010
commit  cc1a34852f02a9304c555fefba470b28f0a6f8b2
tree    40126df5fb268d9172257f103937df68832cb9fd
parent  f126f1ce857f11154a8378fc7e0b04a00d803682
M test/unit/manipulation.js 63 ••••
0
test/unit/manipulation.js
...
12
13
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
16
17
...
133
134
135
136
 
137
138
139
...
158
159
160
161
162
163
164
165
166
167
...
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
...
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
...
169
170
171
 
172
173
174
175
...
194
195
196
 
 
 
 
197
198
199
...
714
715
716
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
717
718
719
0
@@ -12,6 +12,42 @@ test("text()", function() {
0
   equals( jQuery(document.createTextNode("foo")).text(), "foo", "Text node was retreived from .text()." );
0
 });
0
 
0
+var testText = function(valueObj) {
0
+  expect(4);
0
+  var val = valueObj("<div><b>Hello</b> cruel world!</div>");
0
+  equals( jQuery("#foo").text(val)[0].innerHTML.replace(/>/g, "&gt;"), "&lt;div&gt;&lt;b&gt;Hello&lt;/b&gt; cruel world!&lt;/div&gt;", "Check escaped text" );
0
+
0
+  // using contents will get comments regular, text, and comment nodes
0
+  var j = jQuery("#nonnodes").contents();
0
+  j.text(valueObj("hi!"));
0
+  equals( jQuery(j[0]).text(), "hi!", "Check node,textnode,comment with text()" );
0
+  equals( j[1].nodeValue, " there ", "Check node,textnode,comment with text()" );
0
+  equals( j[2].nodeType, 8, "Check node,textnode,comment with text()" );
0
+}
0
+
0
+test("text(String)", function() {
0
+  testText(bareObj)
0
+});
0
+
0
+test("text(Function)", function() {
0
+  testText(functionReturningObj);
0
+});
0
+
0
+test("text(Function) with incoming value", function() {
0
+  expect(2);
0
+  
0
+  var old = "This link has class=\"blog\": Simon Willison's Weblog";
0
+  
0
+  jQuery('#sap').text(function(i, val) {
0
+    equals( val, old, "Make sure the incoming value is correct." );
0
+    return "foobar";
0
+  });
0
+  
0
+  equals( jQuery("#sap").text(), "foobar", 'Check for merged text of more then one element.' );
0
+  
0
+  reset();
0
+});
0
+
0
 var testWrap = function(val) {
0
   expect(18);
0
   var defaultText = 'Try them out:'
0
@@ -133,7 +169,7 @@ test("wrapInner(String|Element)", function() {
0
 //  testWrapInner(functionReturningObj)
0
 // })
0
 
0
-var testUnwrap = function() {
0
+test("unwrap()", function() {
0
   expect(9);
0
 
0
   jQuery("body").append('  <div id="unwrap" style="display: none;"> <div id="unwrap1"> <span class="unwrap">a</span> <span class="unwrap">b</span> </div> <div id="unwrap2"> <span class="unwrap">c</span> <span class="unwrap">d</span> </div> <div id="unwrap3"> <b><span class="unwrap unwrap3">e</span></b> <b><span class="unwrap unwrap3">f</span></b> </div> </div>');
0
@@ -158,10 +194,6 @@ var testUnwrap = function() {
0
   same( jQuery('body > span.unwrap').get(), abcdef, 'body contains 6 .unwrap child spans' );
0
 
0
   jQuery('body > span.unwrap').remove();
0
-}
0
-
0
-test("unwrap()", function() {
0
-  testUnwrap();
0
 });
0
 
0
 var testAppend = function(valueObj) {
0
@@ -682,27 +714,6 @@ test("html(Function)", function() {
0
   testHtml(functionReturningObj);
0
 });
0
 
0
-var testText = function(valueObj) {
0
-  expect(4);
0
-  var val = valueObj("<div><b>Hello</b> cruel world!</div>");
0
-  equals( jQuery("#foo").text(val)[0].innerHTML.replace(/>/g, "&gt;"), "&lt;div&gt;&lt;b&gt;Hello&lt;/b&gt; cruel world!&lt;/div&gt;", "Check escaped text" );
0
-
0
-  // using contents will get comments regular, text, and comment nodes
0
-  var j = jQuery("#nonnodes").contents();
0
-  j.text(valueObj("hi!"));
0
-  equals( jQuery(j[0]).text(), "hi!", "Check node,textnode,comment with text()" );
0
-  equals( j[1].nodeValue, " there ", "Check node,textnode,comment with text()" );
0
-  equals( j[2].nodeType, 8, "Check node,textnode,comment with text()" );
0
-}
0
-
0
-test("text(String)", function() {
0
-  testText(bareObj)
0
-});
0
-
0
-test("text(Function)", function() {
0
-  testText(functionReturningObj);
0
-})
0
-
0
 var testRemove = function(method) {
0
   expect(9);
0
 

Comments

Parsed with GitHub Flavored Markdown
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server
This feature is coming soon. Sit tight!