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

Commit93ca49e

Browse files
authored
Core: Simplify code post browser support reduction
Summary of the changes:* Core: Simplify code post browser support reduction* Tests: Remove legacy jQuery.cache & oldIE leftovers* Tests: Reformat JavaScript in delegatetest.html* Docs: "jQuery Foundation Projects" -> "jQuery Projects"* Tests: Drop an unused localfile.html file (modern browsers don't support the `file:` protocol this way, there's no point in keeping the file around)* Effects: Remove a redundant `!fn` check (`fn || !fn && easing` is equivalent to `fn || easing`; simplify the code)* CSS: Explain the fallback to direct object access in curCSS better* Tests: Deduplicate `jQuery.parseHTML` test titles* Dimensions: Add a test for fractional values* Tests: Fix a buggy WebKit regexClosesgh-5296
1 parent46f6e3d commit93ca49e

File tree

11 files changed

+101
-160
lines changed

11 files changed

+101
-160
lines changed

‎README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ In the spirit of open source software development, jQuery always encourages comm
1212

1313
1.[Getting Involved](https://contribute.jquery.org/)
1414
2.[Core Style Guide](https://contribute.jquery.org/style-guide/js/)
15-
3.[Writing Code for jQueryFoundationProjects](https://contribute.jquery.org/code/)
15+
3.[Writing Code for jQuery Projects](https://contribute.jquery.org/code/)
1616

1717
###References to issues/PRs
1818

‎src/css/curCSS.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ export function curCSS( elem, name, computed ) {
1313
// getPropertyValue is needed for `.css('--customProperty')` (gh-3144)
1414
if(computed){
1515

16+
// A fallback to direct property access is needed as `computed`, being
17+
// the output of `getComputedStyle`, contains camelCased keys and
18+
// `getPropertyValue` requires kebab-case ones.
19+
//
1620
// Support: IE <=9 - 11+
1721
// IE only supports `"float"` in `getPropertyValue`; in computed styles
1822
// it's only available as `"cssFloat"`. We no longer modify properties

‎src/effects.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ jQuery.Animation = jQuery.extend( Animation, {
446446

447447
jQuery.speed=function(speed,easing,fn){
448448
varopt=speed&&typeofspeed==="object" ?jQuery.extend({},speed) :{
449-
complete:fn||!fn&&easing||
449+
complete:fn||easing||
450450
typeofspeed==="function"&&speed,
451451
duration:speed,
452452
easing:fn&&easing||easing&&typeofeasing!=="function"&&easing

‎src/manipulation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ jQuery.each( {
334334
for(;i<=last;i++){
335335
elems=i===last ?this :this.clone(true);
336336
jQuery(insert[i])[original](elems);
337-
push.apply(ret,elems.get());
337+
push.apply(ret,elems);
338338
}
339339

340340
returnthis.pushStack(ret);

‎test/data/testinit.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -144,16 +144,12 @@ this.createXMLFragment = function() {
144144
returnfrag;
145145
};
146146

147-
window.fireNative=document.createEvent ?
148-
function(node,type){
149-
varevent=document.createEvent("HTMLEvents");
150-
151-
event.initEvent(type,true,true);
152-
node.dispatchEvent(event);
153-
} :
154-
function(node,type){
155-
node.fireEvent("on"+type,document.createEventObject());
156-
};
147+
window.fireNative=function(node,type){
148+
varevent=document.createEvent("HTMLEvents");
149+
150+
event.initEvent(type,true,true);
151+
node.dispatchEvent(event);
152+
};
157153

158154
/**
159155
* Add random number to url to stop caching

‎test/delegatetest.html

Lines changed: 61 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -125,103 +125,95 @@ <h2>Submit Tests</h2>
125125

126126
<scripttype='text/javascript'>
127127

128-
$("#fileversion").text($.fn.jquery);
128+
$("#fileversion").text($.fn.jquery);
129129

130130
// Try an auto-submit, it should only fire once
131-
$(function(){
131+
$(function(){
132132
vartriggered=false;
133-
$("#autosub input").trigger("keypress");
134-
$("body").on("submit","#autosub",function(e){
133+
$("#autosub input").trigger("keypress");
134+
$("body").on("submit","#autosub",function(e){
135135
e.preventDefault();
136136
e.stopPropagation();
137137
if(triggered){
138-
alert("autosubmit FAIL");
138+
alert("autosubmit FAIL");
139139
}
140140
triggered=true;
141-
});
142-
$("#autosub").submit().remove();
143-
});
141+
});
142+
$("#autosub").submit().remove();
143+
});
144144

145145
// Events we want to track in row-order
146-
varevents="bind-change live-change onX-change bind-propertychange live-beforeactivate live-focusin bind-focus live-beforedeactivate live-focusout bind-blur live-click live-keydown".split(" "),
146+
varevents="bind-change live-change onX-change bind-propertychange live-beforeactivate live-focusin bind-focus live-beforedeactivate live-focusout bind-blur live-click live-keydown".split(" "),
147147
counter=0;
148-
blinker=function(event){
149-
if(!counter){
150-
$("#changes tbody td").text("");
151-
}
152-
var$el=event.data,
153-
prev=$el.text();
154-
prev=prev?prev+" | " :"";
155-
return$el
156-
.text(prev+++counter+" "+(this.value.replace(/^on$/,"")||this.id||this.checked||""))
157-
.css("backgroundColor","#0f0")
158-
.delay(800)
159-
.queue(function(next){
160-
$el.css("backgroundColor","#afa");
161-
--counter;
162-
next();
163-
});
164-
};
148+
blinker=function(event){
149+
if(!counter){
150+
$("#changes tbody td").text("");
151+
}
152+
var$el=event.data,
153+
prev=$el.text();
154+
prev=prev?prev+" | " :"";
155+
return$el
156+
.text(prev+++counter+" "+(this.value.replace(/^on$/,"")||this.id||this.checked||""))
157+
.css("backgroundColor","#0f0")
158+
.delay(800)
159+
.queue(function(next){
160+
$el.css("backgroundColor","#afa");
161+
--counter;
162+
next();
163+
});
164+
};
165165

166-
for(vari=0;i<events.length;i++){
167-
varm=events[i].split("-"),
168-
api=m[0],
169-
type=m[1],
170-
$row=$("<tr><th>"+type+" "+api+"</th></tr>");
166+
for(vari=0;i<events.length;i++){
167+
varm=events[i].split("-"),
168+
api=m[0],
169+
type=m[1],
170+
$row=$("<tr><th>"+type+" "+api+"</th></tr>");
171171

172-
$("#changes thead td").each(function(){
173-
varid="#"+this.id,
174-
$cell=$("<td></td>");
172+
$("#changes thead td").each(function(){
173+
varid="#"+this.id,
174+
$cell=$("<td></td>");
175175
if(api=="onX"){
176-
$(this).find("input, button, select, textarea").each(function(){
177-
this["on"+type]=function(e){e=$.event.fix(e||event);e.data=$cell;blinker.call(this,e);};
178-
});
176+
$(this).find("input, button, select, textarea").each(function(){
177+
this["on"+type]=function(e){
178+
e=$.event.fix(e||event);e.data=$cell;blinker.call(this,e);
179+
};
180+
});
179181
}elseif(api=="bind"){
180-
$(this).find("input, button, select, textarea").bind(type,$cell,blinker);
182+
$(this).find("input, button, select, textarea").bind(type,$cell,blinker);
181183
}else{
182-
$(id+" input,"+id+" button,"+id+" select,"+id+" textarea").live(type,$cell,blinker);
184+
$(id+" input,"+id+" button,"+id+" select,"+id+" textarea").live(type,$cell,blinker);
183185
}
184-
$row.append($cell);
185-
});
186-
$("#changes tbody").append($row);
187-
}
188-
189-
// Ensure that cloned elements get the delegated event magic; this is
190-
// implementation-specific knowledge but otherwise impossible to test.
191-
// The beforeactivate event attaches a direct-bound change event.
192-
// (Only care about the live change for this third select element.)
193-
varsel1=$("#select-one select:first-child");
194-
if(typeof(sel1[0].fireEvent)!=="undefined"){
195-
sel1.trigger("beforeactivate").clone().appendTo("#select-one");
196-
//alert($("#select-one select").map(function(){ return this._change_attached || "undef"; }).get().join("|"));
186+
$row.append($cell);
187+
});
188+
$("#changes tbody").append($row);
197189
}
198190

199-
jQuery.fn.blink=function(){
191+
jQuery.fn.blink=function(){
200192
returnthis
201-
.css("backgroundColor","green")
202-
.text((parseInt(this.text(),10)||0)+1)
203-
.delay(700).queue(function(next){
204-
jQuery(this).css("backgroundColor","#afa");
193+
.css("backgroundColor","green")
194+
.text((parseInt(this.text(),10)||0)+1)
195+
.delay(700).queue(function(next){
196+
jQuery(this).css("backgroundColor","#afa");
205197
next();
206-
});
198+
});
207199
};
208200

209201
jQuery.fn.addSubmitTest=function(id,prevent){
210-
returnthis.live("submit",function(e){
202+
returnthis.live("submit",function(e){
211203
if(prevent){
212-
e.preventDefault();
204+
e.preventDefault();
213205
}
214-
jQuery(id).blink();
215-
});
206+
jQuery(id).blink();
207+
});
216208
};
217209

218-
$("#text_submit").addSubmitTest("#textSubmit",true);
219-
$("#password_submit").addSubmitTest("#passwordSubmit",true);
220-
$("#submit_submit").addSubmitTest("#submitSubmit",true);
221-
$("#prog_submit").addSubmitTest("#submitSubmit",true);
222-
$(document).bind("submit",function(){
223-
jQuery("#boundSubmit").blink();
224-
});
210+
$("#text_submit").addSubmitTest("#textSubmit",true);
211+
$("#password_submit").addSubmitTest("#passwordSubmit",true);
212+
$("#submit_submit").addSubmitTest("#submitSubmit",true);
213+
$("#prog_submit").addSubmitTest("#submitSubmit",true);
214+
$(document).bind("submit",function(){
215+
jQuery("#boundSubmit").blink();
216+
});
225217

226218
</script>
227219
</body>

‎test/localfile.html

Lines changed: 0 additions & 75 deletions
This file was deleted.

‎test/unit/core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1403,7 +1403,7 @@ QUnit.test( "jQuery.parseHTML(<a href>) - gh-2965", function( assert ) {
14031403
assert.ok(/\/example\.html$/.test(href),"href is not lost after parsing anchor");
14041404
});
14051405

1406-
QUnit.test("jQuery.parseHTML",function(assert){
1406+
QUnit.test("jQuery.parseHTML error handling",function(assert){
14071407
vardone=assert.async();
14081408
assert.expect(1);
14091409

‎test/unit/css.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1757,7 +1757,7 @@ QUnit.testUnlessIE( "css(--customProperty)", function( assert ) {
17571757
vardiv=jQuery("<div>").appendTo("#qunit-fixture"),
17581758
$elem=jQuery("<div>").addClass("test__customProperties")
17591759
.appendTo("#qunit-fixture"),
1760-
webkitOrBlink=/\webkit\b/i.test(navigator.userAgent),
1760+
webkitOrBlink=/webkit\b/i.test(navigator.userAgent),
17611761
expected=20;
17621762

17631763
if(webkitOrBlink){

‎test/unit/dimensions.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,30 @@ QUnit.test( "outerHeight()", function( assert ) {
284284
div.remove();
285285
});
286286

287+
QUnit.test("fractional getters",function(assert){
288+
assert.expect(8);
289+
290+
varelem=jQuery("<div>").css({
291+
width:"10.5px",
292+
height:"20.5px",
293+
border:"10px solid white",
294+
padding:"2px",
295+
margin:"3px"
296+
});
297+
298+
elem.appendTo("#qunit-fixture");
299+
300+
assert.strictEqual(elem.width(),10.5,"width supports fractions");
301+
assert.strictEqual(elem.innerWidth(),14.5,"innerWidth supports fractions");
302+
assert.strictEqual(elem.outerWidth(),34.5,"outerWidth supports fractions");
303+
assert.strictEqual(elem.outerWidth(true),40.5,"outerWidth( true ) supports fractions");
304+
305+
assert.strictEqual(elem.height(),20.5,"height supports fractions");
306+
assert.strictEqual(elem.innerHeight(),24.5,"innerHeight supports fractions");
307+
assert.strictEqual(elem.outerHeight(),44.5,"outerHeight supports fractions");
308+
assert.strictEqual(elem.outerHeight(true),50.5,"outerHeight( true ) supports fractions");
309+
});
310+
287311
QUnit.test("child of a hidden elem (or unconnected node) has accurate inner/outer/Width()/Height() see trac-9441 trac-9300",function(assert){
288312
assert.expect(16);
289313

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp