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

Commit90fed4b

Browse files
authored
Manipulation: Make jQuery.htmlPrefilter an identity function
Closesgh-4642
1 parent5b94a4f commit90fed4b

18 files changed

+255
-262
lines changed

‎src/manipulation.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ import "./event.js";
2323

2424
var
2525

26-
// See https://github.com/eslint/eslint/issues/3229
27-
rxhtmlTag=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,
28-
2926
// Support: IE <=10 - 11+, Edge 12 - 13 only
3027
// In IE/Edge using regex groups here causes severe slowdowns.
3128
// See https://connect.microsoft.com/IE/feedback/details/1736512/
@@ -198,7 +195,7 @@ function remove( elem, selector, keepData ) {
198195

199196
jQuery.extend({
200197
htmlPrefilter:function(html){
201-
returnhtml.replace(rxhtmlTag,"<$1></$2>");
198+
returnhtml;
202199
},
203200

204201
clone:function(elem,dataAndEvents,deepDataAndEvents){

‎test/data/testinit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ this.testIframe = function( title, fileName, func, wrapper ) {
243243
}
244244
wrapper.call(QUnit,title,function(assert){
245245
vardone=assert.async(),
246-
$iframe=supportjQuery("<iframe/>")
246+
$iframe=supportjQuery("<iframe></iframe>")
247247
.css({position:"absolute",top:"0",left:"-600px",width:"500px"})
248248
.attr({id:"qunit-fixture-iframe",src:url(fileName)});
249249

‎test/localfile.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ <h2>
4949
<script>
5050
varlogUL=jQuery("#log");
5151
functiondoLog(message,args){
52-
jQuery("<li />").appendTo(logUL).text(message+': "'+Array.prototype.join.call(args,'" - "')+'"');
52+
jQuery("<li></li>").appendTo(logUL).text(message+': "'+Array.prototype.join.call(args,'" - "')+'"');
5353
}
5454
jQuery.ajax("./data/badjson.js",{
5555
context:jQuery("#success"),

‎test/unit/ajax.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2540,7 +2540,7 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
25402540

25412541
addGlobalEvents("ajaxStart ajaxStop ajaxSend ajaxComplete ajaxError",assert)();
25422542
jQuery(document).on("ajaxStop",done);
2543-
jQuery("<div/>").load(baseURL+"404.txt",function(){
2543+
jQuery("<div></div>").load(baseURL+"404.txt",function(){
25442544
assert.ok(true,"complete");
25452545
});
25462546
});
@@ -2647,7 +2647,7 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
26472647
return"Hello World";
26482648
}
26492649
});
2650-
jQuery("<div/>").load(url("name.html"),function(responseText){
2650+
jQuery("<div></div>").load(url("name.html"),function(responseText){
26512651
assert.strictEqual(jQuery(this).html(),"Hello World","Test div was filled with filtered data");
26522652
assert.strictEqual(responseText,"Hello World","Test callback receives filtered data");
26532653
done();
@@ -2657,7 +2657,7 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
26572657
QUnit.test("jQuery.fn.load( String, Object, Function )",function(assert){
26582658
assert.expect(2);
26592659
vardone=assert.async();
2660-
jQuery("<div />").load(url("mock.php?action=echoHtml"),{
2660+
jQuery("<div></div>").load(url("mock.php?action=echoHtml"),{
26612661
"bar":"ok"
26622662
},function(){
26632663
var$node=jQuery(this);
@@ -2671,7 +2671,7 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
26712671
assert.expect(2);
26722672
vardone=assert.async();
26732673

2674-
jQuery("<div />").load(url("mock.php?action=echoHtml"),"foo=3&bar=ok",function(){
2674+
jQuery("<div></div>").load(url("mock.php?action=echoHtml"),"foo=3&bar=ok",function(){
26752675
var$node=jQuery(this);
26762676
assert.strictEqual($node.find("#method").text(),"GET","Check method");
26772677
assert.ok($node.find("#query").text().match(/foo=3&bar=ok/),"Check if a string of data is passed correctly");

‎test/unit/attributes.js

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@ QUnit.test( "attr(String)", function( assert ) {
9393
assert.equal(jQuery("#area1").attr("maxLength"),"30","Check for maxLength attribute");
9494

9595
// using innerHTML in IE causes href attribute to be serialized to the full path
96-
jQuery("<a/>").attr({
96+
jQuery("<a></a>").attr({
9797
"id":"tAnchor5",
9898
"href":"#5"
9999
}).appendTo("#qunit-fixture");
100100
assert.equal(jQuery("#tAnchor5").attr("href"),"#5","Check for non-absolute href (an anchor)");
101-
jQuery("<a id='tAnchor6' href='#5' />").appendTo("#qunit-fixture");
101+
jQuery("<a id='tAnchor6' href='#5'></a>").appendTo("#qunit-fixture");
102102
assert.equal(jQuery("#tAnchor5").prop("href"),jQuery("#tAnchor6").prop("href"),"Check for absolute href prop on an anchor");
103103

104104
jQuery("<script type='jquery/test' src='#5' id='scriptSrc'></script>").appendTo("#qunit-fixture");
@@ -136,7 +136,7 @@ QUnit.test( "attr(String)", function( assert ) {
136136
assert.equal($img.attr("height"),"53","Retrieve height attribute on an element with display:none.");
137137

138138
// Check for style support
139-
styleElem=jQuery("<div/>").appendTo("#qunit-fixture").css({
139+
styleElem=jQuery("<div></div>").appendTo("#qunit-fixture").css({
140140
background:"url(UPPERlower.gif)"
141141
});
142142
assert.ok(!!~styleElem.attr("style").indexOf("UPPERlower.gif"),"Check style attribute getter");
@@ -158,11 +158,11 @@ QUnit.test( "attr(String)", function( assert ) {
158158
$a=jQuery("<a href='#' onclick='something()'>Click</a>").appendTo("#qunit-fixture");
159159
assert.equal($a.attr("onclick"),"something()","Retrieve ^on attribute without anonymous function wrapper.");
160160

161-
assert.ok(jQuery("<div/>").attr("doesntexist")===undefined,"Make sure undefined is returned when no attribute is found.");
162-
assert.ok(jQuery("<div/>").attr("title")===undefined,"Make sure undefined is returned when no attribute is found.");
163-
assert.equal(jQuery("<div/>").attr("title","something").attr("title"),"something","Set the title attribute.");
161+
assert.ok(jQuery("<div></div>").attr("doesntexist")===undefined,"Make sure undefined is returned when no attribute is found.");
162+
assert.ok(jQuery("<div></div>").attr("title")===undefined,"Make sure undefined is returned when no attribute is found.");
163+
assert.equal(jQuery("<div></div>").attr("title","something").attr("title"),"something","Set the title attribute.");
164164
assert.ok(jQuery().attr("doesntexist")===undefined,"Make sure undefined is returned when no element is there.");
165-
assert.equal(jQuery("<div/>").attr("value"),undefined,"An unset value on a div returns undefined.");
165+
assert.equal(jQuery("<div></div>").attr("value"),undefined,"An unset value on a div returns undefined.");
166166
assert.strictEqual(jQuery("<select><option value='property'></option></select>").attr("value"),undefined,"An unset value on a select returns undefined.");
167167

168168
$form=jQuery("#form").attr("enctype","multipart/form-data");
@@ -180,7 +180,7 @@ QUnit.test( "attr(String) on cloned elements, #9646", function( assert ) {
180180

181181
assert.strictEqual(input.clone(true).attr("name","test")[0].name,"test","Name attribute should be changed on cloned element");
182182

183-
div=jQuery("<div id='tester' />");
183+
div=jQuery("<div id='tester'></div>");
184184
div.attr("id");
185185

186186
assert.strictEqual(div.clone(true).attr("id","test")[0].id,"test","Id attribute should be changed on cloned element");
@@ -299,7 +299,7 @@ QUnit.test( "attr(String, Object)", function( assert ) {
299299
$input=jQuery("<input type='checkbox'/>").attr("checked",true);
300300
assert.equal($input.prop("checked"),true,"Setting checked updates property (verified by .prop)");
301301
assert.equal($input[0].checked,true,"Setting checked updates property (verified by native property)");
302-
$input=jQuery("<option/>").attr("selected",true);
302+
$input=jQuery("<option></option>").attr("selected",true);
303303
assert.equal($input.prop("selected"),true,"Setting selected updates property (verified by .prop)");
304304
assert.equal($input[0].selected,true,"Setting selected updates property (verified by native property)");
305305

@@ -569,7 +569,7 @@ QUnit.test( "removeAttr(String)", function( assert ) {
569569
assert.expect(12);
570570
var$first;
571571

572-
assert.equal(jQuery("<div class='hello' />").removeAttr("class").attr("class"),undefined,"remove class");
572+
assert.equal(jQuery("<div class='hello'></div>").removeAttr("class").attr("class"),undefined,"remove class");
573573
assert.equal(jQuery("#form").removeAttr("id").attr("id"),undefined,"Remove id");
574574
assert.equal(jQuery("#foo").attr("style","position:absolute;").removeAttr("style").attr("style"),undefined,"Check removing style attribute");
575575
assert.equal(jQuery("#form").attr("style","position:absolute;").removeAttr("style").attr("style"),undefined,"Check removing style attribute on a form");
@@ -669,7 +669,7 @@ QUnit.test( "prop(String, Object)", function( assert ) {
669669
assert.equal(jQuery("#select2").prop("selectedIndex"),3,"Check for selectedIndex attribute");
670670
assert.equal(jQuery("#foo").prop("nodeName").toUpperCase(),"DIV","Check for nodeName attribute");
671671
assert.equal(jQuery("#foo").prop("tagName").toUpperCase(),"DIV","Check for tagName attribute");
672-
assert.equal(jQuery("<option/>").prop("selected"),false,"Check selected attribute on disconnected element.");
672+
assert.equal(jQuery("<option></option>").prop("selected"),false,"Check selected attribute on disconnected element.");
673673

674674
assert.equal(jQuery("#listWithTabIndex").prop("tabindex"),5,"Check retrieving tabindex");
675675
jQuery("#text1").prop("readonly",true);
@@ -814,16 +814,16 @@ QUnit.test( "option.prop('selected', true) affects select.selectedIndex (gh-2732
814814

815815
functionaddOptions($elem){
816816
return$elem.append(
817-
jQuery("<option/>").val("a").text("One"),
818-
jQuery("<option/>").val("b").text("Two"),
819-
jQuery("<option/>").val("c").text("Three")
817+
jQuery("<option></option>").val("a").text("One"),
818+
jQuery("<option></option>").val("b").text("Two"),
819+
jQuery("<option></option>").val("c").text("Three")
820820
)
821821
.find("[value=a]").prop("selected",true).end()
822822
.find("[value=c]").prop("selected",true).end();
823823
}
824824

825825
var$optgroup,
826-
$select=jQuery("<select/>");
826+
$select=jQuery("<select></select>");
827827

828828
// Check select with options
829829
addOptions($select).appendTo("#qunit-fixture");
@@ -833,7 +833,7 @@ QUnit.test( "option.prop('selected', true) affects select.selectedIndex (gh-2732
833833
$select.empty();
834834

835835
// Check select with optgroup
836-
$optgroup=jQuery("<optgroup/>");
836+
$optgroup=jQuery("<optgroup></optgroup>");
837837
addOptions($optgroup).appendTo($select);
838838
$select.find("[value=b]").prop("selected",true);
839839

@@ -947,7 +947,7 @@ QUnit.test( "val()", function( assert ) {
947947
assert.equal($button.val(),"foobar","Value retrieval on a button does not return innerHTML");
948948
assert.equal($button.val("baz").html(),"text","Setting the value does not change innerHTML");
949949

950-
assert.equal(jQuery("<option/>").val("test").attr("value"),"test","Setting value sets the value attribute");
950+
assert.equal(jQuery("<option></option>").val("test").attr("value"),"test","Setting value sets the value attribute");
951951
});
952952

953953
QUnit.test("val() with non-matching values on dropdown list",function(assert){
@@ -1014,7 +1014,7 @@ var testVal = function( valueObj, assert ) {
10141014
assert.equal(document.getElementById("text1").value,"","Check for modified (via val(null)) value of input element");
10151015

10161016
varj,
1017-
$select=jQuery("<select multiple><option value='1'/><option value='2'/></select>"),
1017+
$select=jQuery("<select multiple><option value='1'></option><option value='2'></option></select>"),
10181018
$select1=jQuery("#select1");
10191019

10201020
$select1.val(valueObj("3"));
@@ -1130,7 +1130,7 @@ QUnit.test( "val(select) after form.reset() (Bug #2551)", function( assert ) {
11301130
QUnit.test("select.val(space characters) (gh-2978)",function(assert){
11311131
assert.expect(37);
11321132

1133-
var$select=jQuery("<select/>").appendTo("#qunit-fixture"),
1133+
var$select=jQuery("<select></select>").appendTo("#qunit-fixture"),
11341134
spaces={
11351135
"\\t":{
11361136
html:"&#09;",
@@ -1266,7 +1266,7 @@ var testAddClass = function( valueObj, assert ) {
12661266
j.addClass(valueObj("asdf"));
12671267
assert.ok(j.hasClass("asdf"),"Check node,textnode,comment for addClass");
12681268

1269-
div=jQuery("<div/>");
1269+
div=jQuery("<div></div>");
12701270

12711271
div.addClass(valueObj("test"));
12721272
assert.equal(div.attr("class"),"test","Make sure there's no extra whitespace.");
@@ -1697,17 +1697,17 @@ QUnit.test( "coords returns correct values in IE6/IE7, see #10828", function( as
16971697
assert.expect(1);
16981698

16991699
vararea,
1700-
map=jQuery("<map />");
1700+
map=jQuery("<map></map>");
17011701

1702-
area=map.html("<area shape='rect' coords='0,0,0,0' href='#' alt='a' />").find("area");
1702+
area=map.html("<area shape='rect' coords='0,0,0,0' href='#' alt='a'></area>").find("area");
17031703
assert.equal(area.attr("coords"),"0,0,0,0","did not retrieve coords correctly");
17041704
});
17051705

17061706
QUnit.test("should not throw at $(option).val() (#14686)",function(assert){
17071707
assert.expect(1);
17081708

17091709
try{
1710-
jQuery("<option/>").val();
1710+
jQuery("<option></option>").val();
17111711
assert.ok(true);
17121712
}catch(_){
17131713
assert.ok(false);

‎test/unit/basic.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ QUnit.test( "ajax", function( assert ) {
3636
QUnit.test("attributes",function(assert){
3737
assert.expect(6);
3838

39-
vara=jQuery("<a/>").appendTo("#qunit-fixture"),
39+
vara=jQuery("<a></a>").appendTo("#qunit-fixture"),
4040
input=jQuery("<input/>").appendTo("#qunit-fixture");
4141

4242
assert.strictEqual(a.attr("foo","bar").attr("foo"),"bar",".attr getter/setter");
@@ -56,7 +56,7 @@ if ( jQuery.css ) {
5656
QUnit.test("css",function(assert){
5757
assert.expect(1);
5858

59-
vardiv=jQuery("<div/>").appendTo("#qunit-fixture");
59+
vardiv=jQuery("<div></div>").appendTo("#qunit-fixture");
6060

6161
assert.strictEqual(div.css("width","50px").css("width"),"50px",".css getter/setter");
6262
});
@@ -66,7 +66,7 @@ if ( jQuery.fn.show && jQuery.fn.hide ) {
6666
QUnit.test("show/hide",function(assert){
6767
assert.expect(2);
6868

69-
vardiv=jQuery("<div/>").appendTo("#qunit-fixture");
69+
vardiv=jQuery("<div></div>").appendTo("#qunit-fixture");
7070

7171
div.hide();
7272
assert.strictEqual(div.css("display"),"none","div hidden");
@@ -126,7 +126,7 @@ QUnit.test( "core", function( assert ) {
126126
QUnit.test("data",function(assert){
127127
assert.expect(4);
128128

129-
varelem=jQuery("<div data-c='d'/>").appendTo("#qunit-fixture");
129+
varelem=jQuery("<div data-c='d'></div>").appendTo("#qunit-fixture");
130130

131131
assert.ok(!jQuery.hasData(elem[0]),"jQuery.hasData - false");
132132
assert.strictEqual(elem.data("a","b").data("a"),"b",".data getter/setter");
@@ -138,7 +138,7 @@ QUnit.test( "dimensions", function( assert ) {
138138
assert.expect(3);
139139

140140
varelem=jQuery(
141-
"<div style='margin: 10px; padding: 7px; border: 2px solid black;' /> "
141+
"<div style='margin: 10px; padding: 7px; border: 2px solid black;'></div> "
142142
).appendTo("#qunit-fixture");
143143

144144
assert.strictEqual(elem.width(50).width(),50,".width getter/setter");
@@ -149,7 +149,7 @@ QUnit.test( "dimensions", function( assert ) {
149149
QUnit.test("event",function(assert){
150150
assert.expect(1);
151151

152-
varelem=jQuery("<div/>").appendTo("#qunit-fixture");
152+
varelem=jQuery("<div></div>").appendTo("#qunit-fixture");
153153

154154
elem
155155
.on("click",function(){
@@ -168,12 +168,12 @@ QUnit.test( "manipulation", function( assert ) {
168168

169169
varchild,
170170
elem1=jQuery("<div><span></span></div>").appendTo("#qunit-fixture"),
171-
elem2=jQuery("<div/>").appendTo("#qunit-fixture");
171+
elem2=jQuery("<div></div>").appendTo("#qunit-fixture");
172172

173173
assert.strictEqual(elem1.text("foo").text(),"foo",".html getter/setter");
174174

175175
assert.strictEqual(
176-
elem1.html("<span/>").html(),
176+
elem1.html("<span></span>").html(),
177177
"<span></span>",
178178
".html getter/setter"
179179
);
@@ -186,8 +186,8 @@ QUnit.test( "manipulation", function( assert ) {
186186
assert.strictEqual(elem1.prepend(elem2)[0].childNodes[0],elem2[0],".prepend");
187187

188188
child=elem1.find("span");
189-
child.after("<a/>");
190-
child.before("<b/>");
189+
child.after("<a></a>");
190+
child.before("<b></b>");
191191

192192
assert.strictEqual(
193193
elem1.html(),
@@ -201,8 +201,8 @@ QUnit.test( "manipulation", function( assert ) {
201201
QUnit[/jsdom\//.test(navigator.userAgent) ?"skip" :"test"]("offset",function(assert){
202202
assert.expect(3);
203203

204-
varparent=jQuery("<div style='position:fixed;top:20px;'/>").appendTo("#qunit-fixture"),
205-
elem=jQuery("<div style='position:absolute;top:5px;'/>").appendTo(parent);
204+
varparent=jQuery("<div style='position:fixed;top:20px;'></div>").appendTo("#qunit-fixture"),
205+
elem=jQuery("<div style='position:absolute;top:5px;'></div>").appendTo(parent);
206206

207207
assert.strictEqual(elem.offset().top,25,".offset getter");
208208
assert.strictEqual(elem.position().top,5,".position getter");

‎test/unit/core.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ QUnit.test( "jQuery()", function( assert ) {
2323

2424
varelem,i,
2525
obj=jQuery("div"),
26-
code=jQuery("<code/>"),
26+
code=jQuery("<code></code>"),
2727
img=jQuery("<img/>"),
28-
div=jQuery("<div/><hr/><code/><b/>"),
28+
div=jQuery("<div></div><hr/><code></code><b/>"),
2929
exec=false,
3030
expected=23,
3131
attrObj={
@@ -113,7 +113,7 @@ QUnit.test( "jQuery()", function( assert ) {
113113
elem=jQuery("\n\n<em>world</em>")[0];
114114
assert.equal(elem.nodeName.toLowerCase(),"em","leading newlines");
115115

116-
elem=jQuery("<div/>",attrObj);
116+
elem=jQuery("<div></div>",attrObj);
117117

118118
if(jQuery.fn.width){
119119
assert.equal(elem[0].style.width,"10px","jQuery() quick setter width");
@@ -458,7 +458,7 @@ QUnit.test( "jQuery('html')", function( assert ) {
458458

459459
assert.ok(jQuery("<link rel='stylesheet'/>")[0],"Creating a link");
460460

461-
assert.ok(!jQuery("<script/>")[0].parentNode,"Create a script");
461+
assert.ok(!jQuery("<script></script>")[0].parentNode,"Create a script");
462462

463463
assert.ok(jQuery("<input/>").attr("type","hidden"),"Create an input and set the type.");
464464

@@ -526,8 +526,8 @@ QUnit.test( "jQuery('massive html #7990')", function( assert ) {
526526
QUnit.test("jQuery('html', context)",function(assert){
527527
assert.expect(1);
528528

529-
var$div=jQuery("<div/>")[0],
530-
$span=jQuery("<span/>",$div);
529+
var$div=jQuery("<div></div>")[0],
530+
$span=jQuery("<span></span>",$div);
531531
assert.equal($span.length,1,"verify a span created with a div context works, #1763");
532532
});
533533

@@ -1355,7 +1355,7 @@ QUnit.test( "jQuery.parseHTML", function( assert ) {
13551355
assert.equal(jQuery.parseHTML("text")[0].nodeType,3,"Parsing text returns a text node");
13561356
assert.equal(jQuery.parseHTML("\t<div></div>")[0].nodeValue,"\t","Preserve leading whitespace");
13571357

1358-
assert.equal(jQuery.parseHTML(" <div/> ")[0].nodeType,3,"Leading spaces are treated as text nodes (#11290)");
1358+
assert.equal(jQuery.parseHTML(" <div></div> ")[0].nodeType,3,"Leading spaces are treated as text nodes (#11290)");
13591359

13601360
html=jQuery.parseHTML("<div>test div</div>");
13611361

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp