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 @@ -289,9 +289,14 @@ jQuery.extend( {
289289 // Do not traverse comment nodes
290290 ret += jQuery . text ( node ) ;
291291 }
292- } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
292+ }
293+ if ( nodeType === 1 || nodeType === 11 ) {
293294 return elem . textContent ;
294- } else if ( nodeType === 3 || nodeType === 4 ) {
295+ }
296+ if ( nodeType === 9 ) {
297+ return elem . documentElement . textContent ;
298+ }
299+ if ( nodeType === 3 || nodeType === 4 ) {
295300 return elem . nodeValue ;
296301 }
297302
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