<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>49059</bug_id>
          
          <creation_ts>2010-11-05 01:29:19 -0700</creation_ts>
          <short_desc>Unable to remove &apos;important&apos; priority of a CSS shorthand property</short_desc>
          <delta_ts>2022-07-26 21:47:09 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>CSS</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>PC</rep_platform>
          <op_sys>OS X 10.5</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>CONFIGURATION CHANGED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=162263</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Xianzhu Wang">phnixwxz</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>ap</cc>
    
    <cc>bfulgham</cc>
    
    <cc>cdumez</cc>
    
    <cc>ganna.khabibullina</cc>
    
    <cc>ian</cc>
    
    <cc>koivisto</cc>
    
    <cc>menard</cc>
    
    <cc>mitz</cc>
    
    <cc>rniwa</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>wangxianzhu</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>305178</commentid>
    <comment_count>0</comment_count>
      <attachid>73043</attachid>
    <who name="Xianzhu Wang">phnixwxz</who>
    <bug_when>2010-11-05 01:29:19 -0700</bug_when>
    <thetext>Created attachment 73043
test case

&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;&lt;/head&gt;
&lt;body&gt;
&lt;div id=&apos;d1&apos; style=&apos;background: yellow !important&apos;&gt;d1 should be red&lt;/div&gt;
&lt;div id=&apos;d2&apos; style=&apos;background: yellow !important&apos;&gt;d2 should be red&lt;/div&gt;
&lt;div id=&apos;d3&apos; style=&apos;background: yellow !important&apos;&gt;d3 should be red&lt;/div&gt;
&lt;script&gt;
// 1. Unable to change value of an important property by setting JS property.
var d1 = document.getElementById(&apos;d1&apos;);
d1.style.background = &apos;red&apos;;

// 2. Unable to change value of an important property with setProperty().
var d2 = document.getElementById(&apos;d2&apos;);
d2.style.setProperty(&apos;background&apos;, &apos;red&apos;);

// 3. The &apos;important&apos; priority still remains even if the property is removed with removeProperty().
var d3 = document.getElementById(&apos;d3&apos;);
d3.style.removeProperty(&apos;background&apos;);
d3.style.setProperty(&apos;background&apos;, &apos;red&apos;, &apos;&apos;);

// The following will succeed:
// d3.style.setProperty(&apos;background&apos;, &apos;red&apos;, &apos;important&apos;);
// or
// d3.style.background = &apos;red !important&apos;; 

&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;

Firefox also behaves like WebKit. However, the behavior seems unreasonable and not to comply with the draft CSSOM standard. http://dev.w3.org/csswg/cssom/#the-cssstyledeclaration-interface

Anyway, I agree to delay fixing this issue until the CSSOM standard is frozen.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>305496</commentid>
    <comment_count>1</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2010-11-05 13:49:41 -0700</bug_when>
    <thetext>Background is a shorthand property. Does this also affect regular properties?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>305773</commentid>
    <comment_count>2</comment_count>
    <who name="Xianzhu Wang">phnixwxz</who>
    <bug_when>2010-11-06 01:41:56 -0700</bug_when>
    <thetext>Just verified that the issue only affects shorthand properties. Maybe we can merge this bug into bug 49098 because they might be of the same cause?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>554151</commentid>
    <comment_count>3</comment_count>
    <who name="Alexis Menard (darktears)">menard</who>
    <bug_when>2012-02-10 10:19:07 -0800</bug_when>
    <thetext>(In reply to comment #2)
&gt; Just verified that the issue only affects shorthand properties. Maybe we can merge this bug into bug 49098 because they might be of the same cause?

It also affect regular longhand properties.

It seems that it behaves like this on purpose :

https://bugs.webkit.org/show_bug.cgi?id=60007

Now I couldn&apos;t find anything in the spec about Ian&apos;s comment : 
&quot;An element with a !important property in its style will allow you to override this property in JavaScript without using !important.&quot;

If I take the snippet and run it into Opera 11, Firefox 10 it runs as expecting overriding the !important property.

So what should we do here? I&apos;ll be happy to make the patch if a behavior fix is needed.

Ian, Dan???</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>554241</commentid>
    <comment_count>4</comment_count>
    <who name="Ian Henderson">ian</who>
    <bug_when>2012-02-10 11:24:11 -0800</bug_when>
    <thetext>(In reply to comment #3)
&gt; (In reply to comment #2)
&gt; &gt; Just verified that the issue only affects shorthand properties. Maybe we can merge this bug into bug 49098 because they might be of the same cause?
&gt; 
&gt; It also affect regular longhand properties.
&gt; 
&gt; It seems that it behaves like this on purpose :
&gt; 
&gt; https://bugs.webkit.org/show_bug.cgi?id=60007
&gt; 
&gt; Now I couldn&apos;t find anything in the spec about Ian&apos;s comment : 
&gt; &quot;An element with a !important property in its style will allow you to override this property in JavaScript without using !important.&quot;
&gt; 
&gt; If I take the snippet and run it into Opera 11, Firefox 10 it runs as expecting overriding the !important property.
&gt; 
&gt; So what should we do here? I&apos;ll be happy to make the patch if a behavior fix is needed.
&gt; 
&gt; Ian, Dan???

If you have &quot;#elem { background: yellow !important; background: red }&quot; in a stylesheet, should the element end up yellow?  If so, why should the behavior of the JS equivalent be different?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>554255</commentid>
    <comment_count>5</comment_count>
    <who name="Alexis Menard (darktears)">menard</who>
    <bug_when>2012-02-10 11:43:32 -0800</bug_when>
    <thetext>(In reply to comment #4)
&gt; (In reply to comment #3)
&gt; &gt; (In reply to comment #2)
&gt; &gt; &gt; Just verified that the issue only affects shorthand properties. Maybe we can merge this bug into bug 49098 because they might be of the same cause?
&gt; &gt; 
&gt; &gt; It also affect regular longhand properties.
&gt; &gt; 
&gt; &gt; It seems that it behaves like this on purpose :
&gt; &gt; 
&gt; &gt; https://bugs.webkit.org/show_bug.cgi?id=60007
&gt; &gt; 
&gt; &gt; Now I couldn&apos;t find anything in the spec about Ian&apos;s comment : 
&gt; &gt; &quot;An element with a !important property in its style will allow you to override this property in JavaScript without using !important.&quot;
&gt; &gt; 
&gt; &gt; If I take the snippet and run it into Opera 11, Firefox 10 it runs as expecting overriding the !important property.
&gt; &gt; 
&gt; &gt; So what should we do here? I&apos;ll be happy to make the patch if a behavior fix is needed.
&gt; &gt; 
&gt; &gt; Ian, Dan???
&gt; 
&gt; If you have &quot;#elem { background: yellow !important; background: red }&quot; in a stylesheet, should the element end up yellow?  If so, why should the behavior of the JS equivalent be different?

The element should be yellow. Opera and Firefox are doing so. It then means that the behavior is different.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>944108</commentid>
    <comment_count>6</comment_count>
    <who name="Anna">ganna.khabibullina</who>
    <bug_when>2013-10-28 09:11:19 -0700</bug_when>
    <thetext>I don&apos;t believe it&apos;s a bug, this seems to be xbrowser approach. Once set as important you cannot override the style with the other non-important style. Having met the same problem, I did the following:

// Get the style object.
var styleObj= document.getElementById(&apos;foo&apos;).style;

// Remove the property with important priority you want to override. In the example below - height.
styleObj.removeProperty(&apos;height&apos;);

// Set the new value for the property with non-important priority.
 document.getElementById(&apos;foo&apos;).style.setProperty(&apos;height&apos;, &apos;100px&apos;, null);</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1886891</commentid>
    <comment_count>7</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2022-07-26 14:07:57 -0700</bug_when>
    <thetext>I am unable to reproduce this bug using attached test case in Safari 15.6 on macOS 12.6 and Safari show all three lines as red background and it is matched across all other browsers (Chrome Canary 106 and Firefox Nightly 104). 

Safari also pass quite a few tests on WPT while searching for (Important):

https://wpt.fyi/results/css?label=master&amp;label=experimental&amp;aligned&amp;q=important

Just wanted to share updated results, ignore my comment, if I am incorrect here. Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1887001</commentid>
    <comment_count>8</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2022-07-26 21:47:09 -0700</bug_when>
    <thetext>Yeah, this is working now.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>73043</attachid>
            <date>2010-11-05 01:29:19 -0700</date>
            <delta_ts>2010-11-05 01:29:19 -0700</delta_ts>
            <desc>test case</desc>
            <filename>testsetproperty.html</filename>
            <type>text/html</type>
            <size>579</size>
            <attacher name="Xianzhu Wang">phnixwxz</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+CjxodG1sPgo8aGVhZD48L2hlYWQ+Cjxib2R5Pgo8ZGl2IGlkPSdkMScg
c3R5bGU9J2JhY2tncm91bmQ6IHllbGxvdyAhaW1wb3J0YW50Jz5kMSBzaG91bGQgYmUgcmVkPC9k
aXY+CjxkaXYgaWQ9J2QyJyBzdHlsZT0nYmFja2dyb3VuZDogeWVsbG93ICFpbXBvcnRhbnQnPmQy
IHNob3VsZCBiZSByZWQ8L2Rpdj4KPGRpdiBpZD0nZDMnIHN0eWxlPSdiYWNrZ3JvdW5kOiB5ZWxs
b3cgIWltcG9ydGFudCc+ZDMgc2hvdWxkIGJlIHJlZDwvZGl2Pgo8c2NyaXB0Pgp2YXIgZDEgPSBk
b2N1bWVudC5nZXRFbGVtZW50QnlJZCgnZDEnKTsKZDEuc3R5bGUuYmFja2dyb3VuZCA9ICdyZWQn
Owp2YXIgZDIgPSBkb2N1bWVudC5nZXRFbGVtZW50QnlJZCgnZDInKTsKZDIuc3R5bGUuc2V0UHJv
cGVydHkoJ2JhY2tncm91bmQnLCAncmVkJyk7CnZhciBkMyA9IGRvY3VtZW50LmdldEVsZW1lbnRC
eUlkKCdkMycpOwpkMy5zdHlsZS5yZW1vdmVQcm9wZXJ0eSgnYmFja2dyb3VuZCcpOwpkMy5zdHls
ZS5zZXRQcm9wZXJ0eSgnYmFja2dyb3VuZCcsICdyZWQnLCAnJyk7Cjwvc2NyaXB0Pgo8L2JvZHk+
CjwvaHRtbD4K
</data>

          </attachment>
      

    </bug>

</bugzilla>