Skip to content

Commit

Permalink
Fix #14394: Changing style !important in webkit. Close jquerygh-1385.
Browse files Browse the repository at this point in the history
  • Loading branch information
lihanli authored and gibson042 committed Oct 15, 2013
1 parent 6095be1 commit 24e5879
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
6 changes: 6 additions & 0 deletions test/unit/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [{
Expand Down

0 comments on commit 24e5879

Please sign in to comment.