mirror of
https://github.com/jquery/jquery.git
synced 2026-04-20 03:01:22 -04:00
Misc: Drop support for older browsers; update support comments
That includes IE<8, Opera 12.x, Firefox<29, Safari<6.0 and some hacks for old Blackberry. Fixes gh-1836 Fixes gh-1701 Refs gh-1815 Refs gh-1820
This commit is contained in:
committed by
Michał Gołębiowski
parent
a467f8653a
commit
90d7cc1d8b
@@ -7,10 +7,9 @@ define([
|
||||
"../selector"
|
||||
], function( jQuery, rnotwhite, access, support ) {
|
||||
|
||||
var nodeHook, boolHook,
|
||||
var boolHook,
|
||||
attrHandle = jQuery.expr.attrHandle,
|
||||
ruseDefault = /^(?:checked|selected)$/i,
|
||||
getSetAttribute = support.getSetAttribute,
|
||||
getSetInput = support.input;
|
||||
|
||||
jQuery.fn.extend({
|
||||
@@ -45,7 +44,7 @@ jQuery.extend({
|
||||
if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
|
||||
name = name.toLowerCase();
|
||||
hooks = jQuery.attrHooks[ name ] ||
|
||||
( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook );
|
||||
( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );
|
||||
}
|
||||
|
||||
if ( value !== undefined ) {
|
||||
@@ -88,7 +87,7 @@ jQuery.extend({
|
||||
// Boolean attributes get special treatment (#10870)
|
||||
if ( jQuery.expr.match.bool.test( name ) ) {
|
||||
// Set corresponding property to false
|
||||
if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
|
||||
if ( getSetInput || !ruseDefault.test( name ) ) {
|
||||
elem[ propName ] = false;
|
||||
// Support: IE<9
|
||||
// Also clear defaultChecked/defaultSelected (if appropriate)
|
||||
@@ -96,13 +95,9 @@ jQuery.extend({
|
||||
elem[ jQuery.camelCase( "default-" + name ) ] =
|
||||
elem[ propName ] = false;
|
||||
}
|
||||
|
||||
// See #9699 for explanation of this approach (setting first, then removal)
|
||||
} else {
|
||||
jQuery.attr( elem, name, "" );
|
||||
}
|
||||
|
||||
elem.removeAttribute( getSetAttribute ? name : propName );
|
||||
elem.removeAttribute( name );
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -111,7 +106,7 @@ jQuery.extend({
|
||||
type: {
|
||||
set: function( elem, value ) {
|
||||
if ( !support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
|
||||
// Setting the type on a radio button after the value resets the value in IE6-9
|
||||
// Setting the type on a radio button after the value resets the value in IE8-9
|
||||
// Reset value to default in case type is set after value during creation
|
||||
var val = elem.value;
|
||||
elem.setAttribute( "type", value );
|
||||
@@ -131,12 +126,12 @@ boolHook = {
|
||||
if ( value === false ) {
|
||||
// Remove boolean attributes when set to false
|
||||
jQuery.removeAttr( elem, name );
|
||||
} else if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
|
||||
// IE<8 needs the *property* name
|
||||
elem.setAttribute( !getSetAttribute && jQuery.propFix[ name ] || name, name );
|
||||
} else if ( getSetInput || !ruseDefault.test( name ) ) {
|
||||
elem.setAttribute( jQuery.propFix[ name ] || name, name );
|
||||
|
||||
// Use defaultChecked and defaultSelected for oldIE
|
||||
} else {
|
||||
// Support: IE<9
|
||||
// Use defaultChecked and defaultSelected for oldIE
|
||||
elem[ jQuery.camelCase( "default-" + name ) ] = elem[ name ] = true;
|
||||
}
|
||||
|
||||
@@ -149,7 +144,7 @@ jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name )
|
||||
|
||||
var getter = attrHandle[ name ] || jQuery.find.attr;
|
||||
|
||||
attrHandle[ name ] = getSetInput && getSetAttribute || !ruseDefault.test( name ) ?
|
||||
attrHandle[ name ] = getSetInput || !ruseDefault.test( name ) ?
|
||||
function( elem, name, isXML ) {
|
||||
var ret, handle;
|
||||
if ( !isXML ) {
|
||||
@@ -173,88 +168,17 @@ jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name )
|
||||
});
|
||||
|
||||
// fix oldIE attroperties
|
||||
if ( !getSetInput || !getSetAttribute ) {
|
||||
if ( !getSetInput ) {
|
||||
jQuery.attrHooks.value = {
|
||||
set: function( elem, value, name ) {
|
||||
set: function( elem, value ) {
|
||||
if ( jQuery.nodeName( elem, "input" ) ) {
|
||||
// Does not return so that setAttribute is also used
|
||||
elem.defaultValue = value;
|
||||
} else {
|
||||
// Use nodeHook if defined (#1954); otherwise setAttribute is fine
|
||||
return nodeHook && nodeHook.set( elem, value, name );
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// IE6/7 do not support getting/setting some attributes with get/setAttribute
|
||||
if ( !getSetAttribute ) {
|
||||
|
||||
// Use this for any attribute in IE6/7
|
||||
// This fixes almost every IE6/7 issue
|
||||
nodeHook = {
|
||||
set: function( elem, value, name ) {
|
||||
// Set the existing or create a new attribute node
|
||||
var ret = elem.getAttributeNode( name );
|
||||
if ( !ret ) {
|
||||
elem.setAttributeNode(
|
||||
(ret = elem.ownerDocument.createAttribute( name ))
|
||||
);
|
||||
}
|
||||
|
||||
ret.value = value += "";
|
||||
|
||||
// Break association with cloned elements by also using setAttribute (#9646)
|
||||
if ( name === "value" || value === elem.getAttribute( name ) ) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Some attributes are constructed with empty-string values when not defined
|
||||
attrHandle.id = attrHandle.name = attrHandle.coords =
|
||||
function( elem, name, isXML ) {
|
||||
var ret;
|
||||
if ( !isXML ) {
|
||||
return (ret = elem.getAttributeNode( name )) && ret.value !== "" ?
|
||||
ret.value :
|
||||
null;
|
||||
}
|
||||
};
|
||||
|
||||
// Fixing value retrieval on a button requires this module
|
||||
jQuery.valHooks.button = {
|
||||
get: function( elem, name ) {
|
||||
var ret = elem.getAttributeNode( name );
|
||||
if ( ret && ret.specified ) {
|
||||
return ret.value;
|
||||
}
|
||||
},
|
||||
set: nodeHook.set
|
||||
};
|
||||
|
||||
// Set contenteditable to false on removals(#10429)
|
||||
// Setting to empty string throws an error as an invalid value
|
||||
jQuery.attrHooks.contenteditable = {
|
||||
set: function( elem, value, name ) {
|
||||
nodeHook.set( elem, value === "" ? false : value, name );
|
||||
}
|
||||
};
|
||||
|
||||
// Set width and height to auto instead of 0 on empty string( Bug #8150 )
|
||||
// This is for removals
|
||||
jQuery.each([ "width", "height" ], function( i, name ) {
|
||||
jQuery.attrHooks[ name ] = {
|
||||
set: function( elem, value ) {
|
||||
if ( value === "" ) {
|
||||
elem.setAttribute( name, "auto" );
|
||||
return value;
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
if ( !support.style ) {
|
||||
jQuery.attrHooks.style = {
|
||||
get: function( elem ) {
|
||||
|
||||
@@ -80,22 +80,6 @@ jQuery.extend({
|
||||
}
|
||||
});
|
||||
|
||||
// Some attributes require a special call on IE
|
||||
// http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
|
||||
if ( !support.hrefNormalized ) {
|
||||
// href/src property should get the full normalized URL (#10299/#12915)
|
||||
jQuery.each([ "href", "src" ], function( i, name ) {
|
||||
jQuery.propHooks[ name ] = {
|
||||
get: function( elem ) {
|
||||
return elem.getAttribute( name, 4 );
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
// Support: Safari, IE9+
|
||||
// mis-reports the default selected property of an option
|
||||
// Accessing the parent's selectedIndex property fixes it
|
||||
if ( !support.optSelected ) {
|
||||
jQuery.propHooks.selected = {
|
||||
get: function( elem ) {
|
||||
@@ -129,9 +113,4 @@ jQuery.each([
|
||||
jQuery.propFix[ this.toLowerCase() ] = this;
|
||||
});
|
||||
|
||||
// IE6/7 call enctype encoding
|
||||
if ( !support.enctype ) {
|
||||
jQuery.propFix.enctype = "encoding";
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -8,8 +8,7 @@ define([
|
||||
|
||||
// Setup
|
||||
div = document.createElement( "div" );
|
||||
div.setAttribute( "className", "t" );
|
||||
div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
|
||||
div.innerHTML = " <link/><a href='/a'>a</a><input type='checkbox'/>";
|
||||
a = div.getElementsByTagName("a")[ 0 ];
|
||||
|
||||
// First batch of tests.
|
||||
@@ -19,28 +18,18 @@ define([
|
||||
|
||||
a.style.cssText = "top:1px";
|
||||
|
||||
// Test setAttribute on camelCase class.
|
||||
// If it works, we need attrFixes when doing get/setAttribute (ie6/7)
|
||||
support.getSetAttribute = div.className !== "t";
|
||||
|
||||
// Get the style information from getAttribute
|
||||
// (IE uses .cssText instead)
|
||||
support.style = /top/.test( a.getAttribute("style") );
|
||||
|
||||
// Make sure that URLs aren't manipulated
|
||||
// (IE normalizes it by default)
|
||||
support.hrefNormalized = a.getAttribute("href") === "/a";
|
||||
|
||||
// Check the default checkbox/radio value ("" on WebKit; "on" elsewhere)
|
||||
support.checkOn = !!input.value;
|
||||
|
||||
// Support: IE8-11+
|
||||
// Make sure that a selected-by-default option has a working selected property.
|
||||
// (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
|
||||
// (IE defaults to false instead of true if it's in an optgroup)
|
||||
support.optSelected = opt.selected;
|
||||
|
||||
// Tests for enctype support on a form (#6743)
|
||||
support.enctype = !!document.createElement("form").enctype;
|
||||
|
||||
// Make sure that the options inside disabled selects aren't marked as disabled
|
||||
// (WebKit marks them as disabled)
|
||||
select.disabled = true;
|
||||
|
||||
@@ -96,7 +96,8 @@ jQuery.extend({
|
||||
for ( ; i < max; i++ ) {
|
||||
option = options[ i ];
|
||||
|
||||
// oldIE doesn't update selected after form reset (#2551)
|
||||
// Support: IE<10
|
||||
// IE8-9 doesn't update selected after form reset (#2551)
|
||||
if ( ( option.selected || i === index ) &&
|
||||
// Don't return options that are disabled or in a disabled optgroup
|
||||
( support.optDisabled ?
|
||||
@@ -129,24 +130,9 @@ jQuery.extend({
|
||||
|
||||
while ( i-- ) {
|
||||
option = options[ i ];
|
||||
|
||||
if ( jQuery.inArray( jQuery.valHooks.option.get( option ), values ) >= 0 ) {
|
||||
|
||||
// Support: IE6
|
||||
// When new option element is added to select box we need to
|
||||
// force reflow of newly added node in order to workaround delay
|
||||
// of initialization properties
|
||||
try {
|
||||
option.selected = optionSet = true;
|
||||
|
||||
} catch ( _ ) {
|
||||
|
||||
// Will be executed only in IE6
|
||||
option.scrollHeight;
|
||||
}
|
||||
|
||||
} else {
|
||||
option.selected = false;
|
||||
if ( (option.selected =
|
||||
jQuery.inArray( jQuery.valHooks.option.get( option ), values ) >= 0) ) {
|
||||
optionSet = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,8 +158,6 @@ jQuery.each([ "radio", "checkbox" ], function() {
|
||||
};
|
||||
if ( !support.checkOn ) {
|
||||
jQuery.valHooks[ this ].get = function( elem ) {
|
||||
// Support: Webkit
|
||||
// "" is returned instead of "on" if a value isn't specified
|
||||
return elem.getAttribute("value") === null ? "on" : elem.value;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user