Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita75d6b5

Browse files
Krinklemgol
authored andcommitted
Core: Fix regression in jQuery.text() on HTMLDocument objects
Fixesgh-5264Closesgh-5265(cherry picked from commit44c56f8)
1 parent338de35 commita75d6b5

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

‎src/core.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,14 @@ jQuery.extend( {
271271
// Do not traverse comment nodes
272272
ret+=jQuery.text(node);
273273
}
274-
}elseif(nodeType===1||nodeType===9||nodeType===11){
274+
}
275+
if(nodeType===1||nodeType===11){
275276
returnelem.textContent;
276-
}elseif(nodeType===3||nodeType===4){
277+
}
278+
if(nodeType===9){
279+
returnelem.documentElement.textContent;
280+
}
281+
if(nodeType===3||nodeType===4){
277282
returnelem.nodeValue;
278283
}
279284

‎test/unit/manipulation.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ function manipulationFunctionReturningObj( value ) {
3030

3131
QUnit.test("text()",function(assert){
3232

33-
assert.expect(5);
33+
assert.expect(6);
3434

35-
varexpected,frag,$newLineTest;
35+
varexpected,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=newDOMParser().parseFromString("<span>example</span>","text/html");
57+
assert.equal(jQuery(doc).text(),"example","text() on HTMLDocument (gh-5264)");
5558
});
5659

5760
QUnit.test("text(undefined)",function(assert){

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp