mirror of
https://github.com/jquery/jquery.git
synced 2025-01-10 18:24:24 +00:00
Css: Revert 24e587929f
The workaround to be able to change !important styles broke the browser
keeping the old CSS value if the new one was rejected. Patching it would
involve a significant perf hit (~33%) so the initial patch needs to be
reverted instead.
Tests by m_gol & gibson042.
(cherry-picked from 10e654218a
)
Fixes #14836
Closes gh-1532
This commit is contained in:
parent
10e654218a
commit
4a6d1631ea
@ -295,9 +295,6 @@ jQuery.extend({
|
|||||||
// Support: IE
|
// Support: IE
|
||||||
// Swallow errors from 'invalid' CSS values (#5509)
|
// Swallow errors from 'invalid' CSS values (#5509)
|
||||||
try {
|
try {
|
||||||
// Support: Chrome, Safari
|
|
||||||
// Setting style to blank string required to delete "style: x !important;"
|
|
||||||
style[ name ] = "";
|
|
||||||
style[ name ] = value;
|
style[ name ] = value;
|
||||||
} catch(e) {}
|
} catch(e) {}
|
||||||
}
|
}
|
||||||
|
@ -207,7 +207,7 @@ test( "css() explicit and relative values", 29, function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("css(String, Object)", function() {
|
test("css(String, Object)", function() {
|
||||||
expect( 19 );
|
expect( 20 );
|
||||||
var j, div, display, ret, success;
|
var j, div, display, ret, success;
|
||||||
|
|
||||||
jQuery("#nothiddendiv").css("top", "-1em");
|
jQuery("#nothiddendiv").css("top", "-1em");
|
||||||
@ -242,15 +242,18 @@ test("css(String, Object)", function() {
|
|||||||
equal( ret, div, "Make sure setting undefined returns the original set." );
|
equal( ret, div, "Make sure setting undefined returns the original set." );
|
||||||
equal( div.css("display"), display, "Make sure that the display wasn't changed." );
|
equal( div.css("display"), display, "Make sure that the display wasn't changed." );
|
||||||
|
|
||||||
// Test for Bug #5509
|
|
||||||
success = true;
|
success = true;
|
||||||
try {
|
try {
|
||||||
jQuery("#foo").css("backgroundColor", "rgba(0, 0, 0, 0.1)");
|
jQuery( "#foo" ).css( "backgroundColor", "rgba(0, 0, 0, 0.1)" );
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
ok( success, "Setting RGBA values does not throw Error" );
|
ok( success, "Setting RGBA values does not throw Error (#5509)" );
|
||||||
|
|
||||||
|
jQuery( "#foo" ).css( "font", "7px/21px sans-serif" );
|
||||||
|
strictEqual( jQuery( "#foo" ).css( "line-height" ), "21px",
|
||||||
|
"Set font shorthand property (#14759)" );
|
||||||
});
|
});
|
||||||
|
|
||||||
test( "css(Array)", function() {
|
test( "css(Array)", function() {
|
||||||
@ -981,10 +984,20 @@ test( ":visible/:hidden selectors", function() {
|
|||||||
t( "Is Hidden", "#form input:hidden", ["hidden1","hidden2"] );
|
t( "Is Hidden", "#form input:hidden", ["hidden1","hidden2"] );
|
||||||
});
|
});
|
||||||
|
|
||||||
test( "Override !important when changing styles (#14394)", function() {
|
test( "Keep the last style if the new one isn't recognized by the browser (#14836)", function() {
|
||||||
|
expect( 2 );
|
||||||
|
|
||||||
|
var el;
|
||||||
|
el = jQuery( "<div></div>" ).css( "color", "black" ).css( "color", "fake value" );
|
||||||
|
equal( el.css( "color" ), "black", "The old style is kept when setting an unrecognized value" );
|
||||||
|
el = jQuery( "<div></div>" ).css( "color", "black" ).css( "color", " " );
|
||||||
|
equal( el.css( "color" ), "black", "The old style is kept when setting to a space" );
|
||||||
|
});
|
||||||
|
|
||||||
|
test( "Reset the style if set to an empty string", function() {
|
||||||
expect( 1 );
|
expect( 1 );
|
||||||
var el = jQuery( "<div style='display: block !important;'></div>" ).css( "display", "none" );
|
var el = jQuery( "<div></div>" ).css( "color", "black" ).css( "color", "" );
|
||||||
equal( el.css( "display" ), "none", "New style replaced !important" );
|
equal( el.css( "color" ), "", "The style can be reset by setting to an empty string" );
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest( "Clearing a Cloned Element's Style Shouldn't Clear the Original Element's Style (#8908)", 24, function() {
|
asyncTest( "Clearing a Cloned Element's Style Shouldn't Clear the Original Element's Style (#8908)", 24, function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user