<?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>247810</bug_id>
          
          <creation_ts>2022-11-11 08:50:47 -0800</creation_ts>
          <short_desc>border shorthand serialization doesn&apos;t round-trip</short_desc>
          <delta_ts>2026-02-04 22:20:02 -0800</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>Other</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=247498</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Emilio Cobos Álvarez (:emilio)">emilio</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>darin</cc>
    
    <cc>ntim</cc>
    
    <cc>obrufau</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1911826</commentid>
    <comment_count>0</comment_count>
    <who name="Emilio Cobos Álvarez (:emilio)">emilio</who>
    <bug_when>2022-11-11 08:50:47 -0800</bug_when>
    <thetext>document.body.style.border = &quot;1px solid&quot;;
document.body.style.borderImageSlice = &quot;99%&quot;; // Something non-initial
document.body.style.border // Should be &quot;&quot;, on WebKit is &quot;1px solid&quot;

Per spec it should be the empty string.

https://drafts.csswg.org/cssom/#serialize-a-css-value:

&gt; If there is no such shorthand or shorthand cannot exactly represent the values of all the properties in list, return the empty string.

The list comes from https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-getpropertyvalue which has:

&gt; For each longhand property longhand that property maps to, in canonical order [...]

And border maps to the border-image properties.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1911873</commentid>
    <comment_count>1</comment_count>
    <who name="Oriol Brufau">obrufau</who>
    <bug_when>2022-11-11 11:35:04 -0800</bug_when>
    <thetext>This also affects other properties, as can be easily shown by the fact that WebKit doesn&apos;t even ensure that all longhands are present.

var allCSSProps = new Set();
for (let obj = document.createElement(&quot;div&quot;).style; obj; obj = Reflect.getPrototypeOf(obj)) {
  for (let name of Object.getOwnPropertyNames(obj)) {
    let prop = name.replace(/[A-Z]/g, c =&gt; &quot;-&quot; + c.toLowerCase());
    if (CSS.supports(prop, &quot;initial&quot;)) {
      allCSSProps.add(prop);
    }
  }
}
var style = document.createElement(&quot;div&quot;).style;
document.documentElement.style.cssText = &quot;all: initial; direction: initial; unicode-bidi: initial&quot;;
var cs = getComputedStyle(document.documentElement);
var bad = {};
for (let prop of allCSSProps) {
  const value = cs.getPropertyValue(prop);
  style.cssText = &quot;&quot;;
  style.setProperty(prop, value);
  if (style.length &gt; 1) {
    let longhands = [...style];
    for (let longhand of longhands) {
      style.cssText = &quot;&quot;;
      style.setProperty(prop, value);
      style.removeProperty(longhand);
      if (style.getPropertyValue(prop) !== &quot;&quot;) {
        bad[prop] ||= [];
        bad[prop].push(longhand);
      }
    }
  }
}
bad;


{
  border: [&quot;border-image-source&quot;, &quot;border-image-slice&quot;, &quot;border-image-width&quot;, &quot;border-image-outset&quot;, &quot;border-image-repeat&quot;],
  font: [&quot;font-style&quot;, &quot;font-variant-caps&quot;, &quot;font-weight&quot;, &quot;font-stretch&quot;, &quot;line-height&quot;, &quot;font-size-adjust&quot;, &quot;font-kerning&quot;, &quot;font-variant-alternates&quot;, &quot;font-variant-ligatures&quot;, &quot;font-variant-numeric&quot;, &quot;font-variant-east-asian&quot;, &quot;font-variant-position&quot;, &quot;font-feature-settings&quot;, &quot;font-optical-sizing&quot;, &quot;font-variation-settings&quot;, &quot;font-palette&quot;],
  font-synthesis: [&quot;font-synthesis-weight&quot;, &quot;font-synthesis-style&quot;, &quot;font-synthesis-small-caps&quot;],
  font-variant: [&quot;font-variant-numeric&quot;, &quot;font-variant-caps&quot;, &quot;font-variant-alternates&quot;, &quot;font-variant-east-asian&quot;, &quot;font-variant-position&quot;],
  offset: [&quot;offset-path&quot;, &quot;offset-distance&quot;, &quot;offset-position&quot;, &quot;offset-anchor&quot;, &quot;offset-rotate&quot;],
}</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1912006</commentid>
    <comment_count>2</comment_count>
    <who name="Tim Nguyen (:ntim)">ntim</who>
    <bug_when>2022-11-12 10:18:05 -0800</bug_when>
    <thetext>Are there any WPT for this? It would be nice to add some if not.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1912012</commentid>
    <comment_count>3</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2022-11-12 10:50:03 -0800</bug_when>
    <thetext>Tests should cover both specified properties and computed properties. For specified values of shorthands it’s important to cover cases when the longhands are set to CSS-wide keywords like &quot;inherit&quot; and &quot;initial&quot;.

Aside from this, I think we also might want tests for what longhands get set to when the specification says &quot;reset to the initial value&quot; because you could imagine that could serialize as &quot;initial&quot; or as &quot;normal&quot;, for example.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1912024</commentid>
    <comment_count>4</comment_count>
    <who name="Oriol Brufau">obrufau</who>
    <bug_when>2022-11-12 12:58:56 -0800</bug_when>
    <thetext>It should not be literally &quot;initial&quot;, see e.g. bug 82078 and bug 244657
Using &quot;initial&quot; causes bugs like bug 242775.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1912161</commentid>
    <comment_count>5</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2022-11-13 20:35:56 -0800</bug_when>
    <thetext>I don’t mean how it will serialize in the shorthand. I meant how it should serialize in the longhand.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1912162</commentid>
    <comment_count>6</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2022-11-13 20:36:49 -0800</bug_when>
    <thetext>But I assume that most shorthands never say &quot;reset to the initial value&quot;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1912163</commentid>
    <comment_count>7</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2022-11-13 20:37:00 -0800</bug_when>
    <thetext>The font shorthand does, but maybe that’s the only one.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1912165</commentid>
    <comment_count>8</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2022-11-13 20:37:53 -0800</bug_when>
    <thetext>Without existing WPT, the main task here is writing the tests. It will be very quick to fix the code once we have the tests.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1912215</commentid>
    <comment_count>9</comment_count>
    <who name="Tim Nguyen (:ntim)">ntim</who>
    <bug_when>2022-11-14 01:14:15 -0800</bug_when>
    <thetext>The border/border-image case is tested by LayoutTests/imported/w3c/web-platform-tests/css/cssom/border-shorthand-serialization.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1912315</commentid>
    <comment_count>10</comment_count>
    <who name="Oriol Brufau">obrufau</who>
    <bug_when>2022-11-14 08:06:33 -0800</bug_when>
    <thetext>(In reply to Darin Adler from comment #6)
&gt; But I assume that most shorthands never say &quot;reset to the initial value&quot;.

I think it&apos;s quite common.

https://drafts.csswg.org/css-backgrounds/#border-shorthands
&gt; Omitted values are set to their initial values. 
&gt; The border shorthand also resets border-image to its initial value.

https://drafts.csswg.org/css-backgrounds/#background
&gt; &apos;background-color&apos; is set to the specified color, if any, else set to its initial value. 

https://drafts.fxtf.org/motion/#offset-shorthand
&gt; Omitted values are set to their initial values.

https://drafts.csswg.org/css-grid/#valdef-grid-template-none
&gt; Sets all three properties to their initial values (&apos;none&apos;). 

https://drafts.csswg.org/css-grid/#grid-shorthand
&gt; the &apos;grid-auto-*&apos; longhands to their initial values.
&gt; All other grid sub-properties are reset to their initial values.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1913469</commentid>
    <comment_count>11</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2022-11-18 08:51:15 -0800</bug_when>
    <thetext>&lt;rdar://problem/102516427&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2178268</commentid>
    <comment_count>12</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2026-02-04 22:20:02 -0800</bug_when>
    <thetext>https://wpt.fyi/results/css/cssom/border-shorthand-serialization.html?label=master&amp;label=experimental&amp;aligned

All browsers match each other in above test, do we need to do anything here?</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>