Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix #14394: Changing style !important in webkit. Close gh-1385.

  • Loading branch information...
commit 24e587929f62428e1959b10aace6dc4fd65ab397 1 parent 6095be1
@lihanli lihanli authored gibson042 committed
Showing with 9 additions and 0 deletions.
  1. +3 −0  src/css.js
  2. +6 −0 test/unit/css.js
View
3  src/css.js
@@ -286,6 +286,9 @@ jQuery.extend({
// If a hook was provided, use that value, otherwise just set the specified value
if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
+ // Support: Chrome, Safari
+ // Setting style to blank string required to delete "style: x !important;"
+ style[ name ] = "";
style[ name ] = value;
}
View
6 test/unit/css.js
@@ -925,6 +925,12 @@ test( ":visible/:hidden selectors", function() {
t( "Is Hidden", "#form input:hidden", ["hidden1","hidden2"] );
});
+test( "Override !important when changing styles (#14394)", function() {
+ expect( 1 );
+ var el = jQuery( "<div style='display: block !important;'></div>" ).css( "display", "none" );
+ equal( el.css( "display" ), "none", "New style replaced !important" );
+});
+
asyncTest( "Clearing a Cloned Element's Style Shouldn't Clear the Original Element's Style (#8908)", 24, function() {
var baseUrl = document.location.href.replace( /([^\/]*)$/, "" ),
styles = [{
Please sign in to comment.
Something went wrong with that request. Please try again.