mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
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 regex Closes gh-5296
This commit is contained in:
parent
46f6e3da79
commit
93ca49e6d1
@ -12,7 +12,7 @@ In the spirit of open source software development, jQuery always encourages comm
|
|||||||
|
|
||||||
1. [Getting Involved](https://contribute.jquery.org/)
|
1. [Getting Involved](https://contribute.jquery.org/)
|
||||||
2. [Core Style Guide](https://contribute.jquery.org/style-guide/js/)
|
2. [Core Style Guide](https://contribute.jquery.org/style-guide/js/)
|
||||||
3. [Writing Code for jQuery Foundation Projects](https://contribute.jquery.org/code/)
|
3. [Writing Code for jQuery Projects](https://contribute.jquery.org/code/)
|
||||||
|
|
||||||
### References to issues/PRs
|
### References to issues/PRs
|
||||||
|
|
||||||
|
@ -13,6 +13,10 @@ export function curCSS( elem, name, computed ) {
|
|||||||
// getPropertyValue is needed for `.css('--customProperty')` (gh-3144)
|
// getPropertyValue is needed for `.css('--customProperty')` (gh-3144)
|
||||||
if ( computed ) {
|
if ( computed ) {
|
||||||
|
|
||||||
|
// A fallback to direct property access is needed as `computed`, being
|
||||||
|
// the output of `getComputedStyle`, contains camelCased keys and
|
||||||
|
// `getPropertyValue` requires kebab-case ones.
|
||||||
|
//
|
||||||
// Support: IE <=9 - 11+
|
// Support: IE <=9 - 11+
|
||||||
// IE only supports `"float"` in `getPropertyValue`; in computed styles
|
// IE only supports `"float"` in `getPropertyValue`; in computed styles
|
||||||
// it's only available as `"cssFloat"`. We no longer modify properties
|
// it's only available as `"cssFloat"`. We no longer modify properties
|
||||||
|
2
src/effects.js
vendored
2
src/effects.js
vendored
@ -446,7 +446,7 @@ jQuery.Animation = jQuery.extend( Animation, {
|
|||||||
|
|
||||||
jQuery.speed = function( speed, easing, fn ) {
|
jQuery.speed = function( speed, easing, fn ) {
|
||||||
var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
|
var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
|
||||||
complete: fn || !fn && easing ||
|
complete: fn || easing ||
|
||||||
typeof speed === "function" && speed,
|
typeof speed === "function" && speed,
|
||||||
duration: speed,
|
duration: speed,
|
||||||
easing: fn && easing || easing && typeof easing !== "function" && easing
|
easing: fn && easing || easing && typeof easing !== "function" && easing
|
||||||
|
@ -334,7 +334,7 @@ jQuery.each( {
|
|||||||
for ( ; i <= last; i++ ) {
|
for ( ; i <= last; i++ ) {
|
||||||
elems = i === last ? this : this.clone( true );
|
elems = i === last ? this : this.clone( true );
|
||||||
jQuery( insert[ i ] )[ original ]( elems );
|
jQuery( insert[ i ] )[ original ]( elems );
|
||||||
push.apply( ret, elems.get() );
|
push.apply( ret, elems );
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.pushStack( ret );
|
return this.pushStack( ret );
|
||||||
|
@ -144,15 +144,11 @@ this.createXMLFragment = function() {
|
|||||||
return frag;
|
return frag;
|
||||||
};
|
};
|
||||||
|
|
||||||
window.fireNative = document.createEvent ?
|
window.fireNative = function( node, type ) {
|
||||||
function( node, type ) {
|
|
||||||
var event = document.createEvent( "HTMLEvents" );
|
var event = document.createEvent( "HTMLEvents" );
|
||||||
|
|
||||||
event.initEvent( type, true, true );
|
event.initEvent( type, true, true );
|
||||||
node.dispatchEvent( event );
|
node.dispatchEvent( event );
|
||||||
} :
|
|
||||||
function( node, type ) {
|
|
||||||
node.fireEvent( "on" + type, document.createEventObject() );
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -174,7 +174,9 @@ for ( var i=0; i < events.length; i++ ) {
|
|||||||
$cell = $( "<td></td>" );
|
$cell = $( "<td></td>" );
|
||||||
if ( api == "onX" ) {
|
if ( api == "onX" ) {
|
||||||
$( this ).find( "input, button, select, textarea" ).each( function() {
|
$( this ).find( "input, button, select, textarea" ).each( function() {
|
||||||
this["on"+type] = function(e){ e = $.event.fix(e||event); e.data = $cell; blinker.call(this, e); };
|
this[ "on" + type ] = function( e ) {
|
||||||
|
e = $.event.fix( e || event ); e.data = $cell; blinker.call( this, e );
|
||||||
|
};
|
||||||
} );
|
} );
|
||||||
} else if ( api == "bind" ) {
|
} else if ( api == "bind" ) {
|
||||||
$( this ).find( "input, button, select, textarea" ).bind( type, $cell, blinker );
|
$( this ).find( "input, button, select, textarea" ).bind( type, $cell, blinker );
|
||||||
@ -186,16 +188,6 @@ for ( var i=0; i < events.length; i++ ) {
|
|||||||
$( "#changes tbody" ).append( $row );
|
$( "#changes tbody" ).append( $row );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure that cloned elements get the delegated event magic; this is
|
|
||||||
// implementation-specific knowledge but otherwise impossible to test.
|
|
||||||
// The beforeactivate event attaches a direct-bound change event.
|
|
||||||
// (Only care about the live change for this third select element.)
|
|
||||||
var sel1 = $("#select-one select:first-child");
|
|
||||||
if ( typeof(sel1[0].fireEvent) !== "undefined" ) {
|
|
||||||
sel1.trigger( "beforeactivate" ).clone().appendTo("#select-one");
|
|
||||||
//alert($("#select-one select").map(function(){ return this._change_attached || "undef"; }).get().join("|"));
|
|
||||||
}
|
|
||||||
|
|
||||||
jQuery.fn.blink = function() {
|
jQuery.fn.blink = function() {
|
||||||
return this
|
return this
|
||||||
.css( "backgroundColor", "green" )
|
.css( "backgroundColor", "green" )
|
||||||
|
@ -1,75 +0,0 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr" id="html">
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
||||||
<title>jQuery Local File Test</title>
|
|
||||||
<!-- Includes -->
|
|
||||||
<script src="jquery.js"></script>
|
|
||||||
<style>
|
|
||||||
.error { color: red; }
|
|
||||||
.success { color: green; }
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>jQuery Local File Test</h1>
|
|
||||||
<h2>
|
|
||||||
Introduction
|
|
||||||
</h2>
|
|
||||||
<ul>
|
|
||||||
<li>
|
|
||||||
Access this file using the "file:" protocol,
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
two green "OK" strings must appear below,
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
Empty local files will issue errors, it's a known limitation.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<h2>
|
|
||||||
Results
|
|
||||||
</h2>
|
|
||||||
<ul>
|
|
||||||
<li>
|
|
||||||
Success:
|
|
||||||
<span id="success">
|
|
||||||
</span>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
Error:
|
|
||||||
<span id="error">
|
|
||||||
</span>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<h2>
|
|
||||||
Logs:
|
|
||||||
</h2>
|
|
||||||
<ul id="log">
|
|
||||||
</ul>
|
|
||||||
<script>
|
|
||||||
var logUL = jQuery( "#log" );
|
|
||||||
function doLog( message, args ) {
|
|
||||||
jQuery( "<li></li>" ).appendTo( logUL ).text( message + ': "' + Array.prototype.join.call( args, '" - "' ) + '"' );
|
|
||||||
}
|
|
||||||
jQuery.ajax( "./data/badjson.js" , {
|
|
||||||
context: jQuery( "#success" ),
|
|
||||||
dataType: "text"
|
|
||||||
}).success(function( data, _, xhr ) {
|
|
||||||
doLog( "Success (" + xhr.status + ")" , arguments );
|
|
||||||
this.addClass( data ? "success" : "error" ).text( "OK" );
|
|
||||||
}).error(function( xhr ) {
|
|
||||||
doLog( "Success (" + xhr.status + ")" , arguments );
|
|
||||||
this.addClass( "error" ).text( "FAIL" );
|
|
||||||
});
|
|
||||||
jQuery.ajax( "./data/doesnotexist.ext" , {
|
|
||||||
context: jQuery( "#error" ),
|
|
||||||
dataType: "text"
|
|
||||||
}).error(function( xhr ) {
|
|
||||||
doLog( "Error (" + xhr.status + ")" , arguments );
|
|
||||||
this.addClass( "success" ).text( "OK" );
|
|
||||||
}).success(function( data, _, xhr ) {
|
|
||||||
doLog( "Error (" + xhr.status + ")" , arguments );
|
|
||||||
this.addClass( "error" ).text( "FAIL" );
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
</body>
|
|
@ -1403,7 +1403,7 @@ QUnit.test( "jQuery.parseHTML(<a href>) - gh-2965", function( assert ) {
|
|||||||
assert.ok( /\/example\.html$/.test( href ), "href is not lost after parsing anchor" );
|
assert.ok( /\/example\.html$/.test( href ), "href is not lost after parsing anchor" );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
QUnit.test( "jQuery.parseHTML", function( assert ) {
|
QUnit.test( "jQuery.parseHTML error handling", function( assert ) {
|
||||||
var done = assert.async();
|
var done = assert.async();
|
||||||
assert.expect( 1 );
|
assert.expect( 1 );
|
||||||
|
|
||||||
|
@ -1757,7 +1757,7 @@ QUnit.testUnlessIE( "css(--customProperty)", function( assert ) {
|
|||||||
var div = jQuery( "<div>" ).appendTo( "#qunit-fixture" ),
|
var div = jQuery( "<div>" ).appendTo( "#qunit-fixture" ),
|
||||||
$elem = jQuery( "<div>" ).addClass( "test__customProperties" )
|
$elem = jQuery( "<div>" ).addClass( "test__customProperties" )
|
||||||
.appendTo( "#qunit-fixture" ),
|
.appendTo( "#qunit-fixture" ),
|
||||||
webkitOrBlink = /\webkit\b/i.test( navigator.userAgent ),
|
webkitOrBlink = /webkit\b/i.test( navigator.userAgent ),
|
||||||
expected = 20;
|
expected = 20;
|
||||||
|
|
||||||
if ( webkitOrBlink ) {
|
if ( webkitOrBlink ) {
|
||||||
|
@ -284,6 +284,30 @@ QUnit.test( "outerHeight()", function( assert ) {
|
|||||||
div.remove();
|
div.remove();
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
QUnit.test( "fractional getters", function( assert ) {
|
||||||
|
assert.expect( 8 );
|
||||||
|
|
||||||
|
var elem = jQuery( "<div>" ).css( {
|
||||||
|
width: "10.5px",
|
||||||
|
height: "20.5px",
|
||||||
|
border: "10px solid white",
|
||||||
|
padding: "2px",
|
||||||
|
margin: "3px"
|
||||||
|
} );
|
||||||
|
|
||||||
|
elem.appendTo( "#qunit-fixture" );
|
||||||
|
|
||||||
|
assert.strictEqual( elem.width(), 10.5, "width supports fractions" );
|
||||||
|
assert.strictEqual( elem.innerWidth(), 14.5, "innerWidth supports fractions" );
|
||||||
|
assert.strictEqual( elem.outerWidth(), 34.5, "outerWidth supports fractions" );
|
||||||
|
assert.strictEqual( elem.outerWidth( true ), 40.5, "outerWidth( true ) supports fractions" );
|
||||||
|
|
||||||
|
assert.strictEqual( elem.height(), 20.5, "height supports fractions" );
|
||||||
|
assert.strictEqual( elem.innerHeight(), 24.5, "innerHeight supports fractions" );
|
||||||
|
assert.strictEqual( elem.outerHeight(), 44.5, "outerHeight supports fractions" );
|
||||||
|
assert.strictEqual( elem.outerHeight( true ), 50.5, "outerHeight( true ) supports fractions" );
|
||||||
|
} );
|
||||||
|
|
||||||
QUnit.test( "child of a hidden elem (or unconnected node) has accurate inner/outer/Width()/Height() see trac-9441 trac-9300", function( assert ) {
|
QUnit.test( "child of a hidden elem (or unconnected node) has accurate inner/outer/Width()/Height() see trac-9441 trac-9300", function( assert ) {
|
||||||
assert.expect( 16 );
|
assert.expect( 16 );
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ function testWrap( val, assert ) {
|
|||||||
|
|
||||||
assert.expect( 18 );
|
assert.expect( 18 );
|
||||||
|
|
||||||
var defaultText, result, j, i, cacheLength;
|
var defaultText, result, j;
|
||||||
|
|
||||||
defaultText = "Try them out:";
|
defaultText = "Try them out:";
|
||||||
result = jQuery( "#first" ).wrap( val( "<div class='red'><span></span></div>" ) ).text();
|
result = jQuery( "#first" ).wrap( val( "<div class='red'><span></span></div>" ) ).text();
|
||||||
|
Loading…
Reference in New Issue
Block a user