Commit 24e58792 authored by Lihan Li's avatar Lihan Li Committed by Richard Gibson

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

parent 6095be12
...@@ -286,6 +286,9 @@ jQuery.extend({ ...@@ -286,6 +286,9 @@ jQuery.extend({
// If a hook was provided, use that value, otherwise just set the specified value // 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 ) { 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; style[ name ] = value;
} }
......
...@@ -925,6 +925,12 @@ test( ":visible/:hidden selectors", function() { ...@@ -925,6 +925,12 @@ 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() {
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() { asyncTest( "Clearing a Cloned Element's Style Shouldn't Clear the Original Element's Style (#8908)", 24, function() {
var baseUrl = document.location.href.replace( /([^\/]*)$/, "" ), var baseUrl = document.location.href.replace( /([^\/]*)$/, "" ),
styles = [{ styles = [{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment