File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed
Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -271,9 +271,14 @@ jQuery.extend( {
271271 // Do not traverse comment nodes
272272 ret += jQuery . text ( node ) ;
273273 }
274- } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
274+ }
275+ if ( nodeType === 1 || nodeType === 11 ) {
275276 return elem . textContent ;
276- } else if ( nodeType === 3 || nodeType === 4 ) {
277+ }
278+ if ( nodeType === 9 ) {
279+ return elem . documentElement . textContent ;
280+ }
281+ if ( nodeType === 3 || nodeType === 4 ) {
277282 return elem . nodeValue ;
278283 }
279284
Original file line number Diff line number Diff line change @@ -30,9 +30,9 @@ function manipulationFunctionReturningObj( value ) {
3030
3131QUnit . test ( "text()" , function ( assert ) {
3232
33- assert . expect ( 5 ) ;
33+ assert . expect ( 6 ) ;
3434
35- var expected , frag , $newLineTest ;
35+ var expected , frag , $newLineTest , doc ;
3636
3737 expected = "This link has class=\"blog\": Simon Willison's Weblog" ;
3838 assert . equal ( jQuery ( "#sap" ) . text ( ) , expected , "Check for merged text of more then one element." ) ;
@@ -52,6 +52,9 @@ QUnit.test( "text()", function( assert ) {
5252 assert . equal ( $newLineTest . text ( ) , "test\ntesty" , "text() does not remove new lines (trac-11153)" ) ;
5353
5454 $newLineTest . remove ( ) ;
55+
56+ doc = new DOMParser ( ) . parseFromString ( "<span>example</span>" , "text/html" ) ;
57+ assert . equal ( jQuery ( doc ) . text ( ) , "example" , "text() on HTMLDocument (gh-5264)" ) ;
5558} ) ;
5659
5760QUnit . test ( "text(undefined)" , function ( assert ) {
You can’t perform that action at this time.
0 commit comments