diff --git a/cssom-1/Overview.bs b/cssom-1/Overview.bs index e4611b50dcb..2445966d892 100644 --- a/cssom-1/Overview.bs +++ b/cssom-1/Overview.bs @@ -118,6 +118,8 @@ spec:html; type:dfn; text:ascii case-insensitive spec:html; type:dfn; text:case-sensitive spec:infra; type:dfn; text:list spec:css-logical; type:property; text:inline-size +spec:css-logical; type:dfn; text:logical property group +spec:css-logical; type:dfn; text:logical kind spec:css-variables-1; type:dfn; text:custom property spec:selectors-3; type:selector; text:::before spec:selectors-3; type:selector; text:::after @@ -2190,28 +2192,101 @@ The setProperty(property, va Note: value can not include "!important".
  • If component value list is null, then return. +
  • Let updated be false.
  • If property is a shorthand property, then for each longhand property longhand that property maps to, in canonical - order, set the CSS declaration longhand with the appropriate value(s) from component value - list, with the important flag set if priority is not the empty string, and unset otherwise, and with the list of declarations being the - declarations. -
  • Otherwise, set the CSS declaration property with value component value list, with - the important flag set if priority is not the empty string, and unset otherwise, and with the list of declarations being the + order, follow these substeps: +
      +
    1. Let longhand result be the result of set the CSS declaration + longhand with the appropriate value(s) from component value list, with the important + flag set if priority is not the empty string, and unset otherwise, and with the list of declarations + being the declarations. +
    2. If longhand result is true, let updated be true. +
    +
  • Otherwise, let updated be the result of set the CSS declaration + property with value component value list, with the important flag set if + priority is not the empty string, and unset otherwise, and with the list of declarations being the declarations. -
  • Update style attribute for the CSS declaration block. +
  • If updated is true, update style attribute for the CSS declaration block. To set a CSS declaration property with a value component value list and optionally with an important flag set, in -a list of declarations declarations, follow these steps: +a list of declarations declarations, the user agent must ensure the following constraints hold after its steps: -
      -
    1. If property is a case-sensitive match for a property - name of a CSS declaration in declarations, remove that CSS declaration. -
    2. Append a new CSS declaration with the property name property - to declarations and let declaration be that CSS declaration. -
    3. Set declaration's value to component value list. -
    4. If the important flag is set, set declaration's important flag. - Otherwise, unset declaration's important flag. -
    +
      +
    • + Exactly one CSS declaration whose property name is a + case-sensitive match of property must exist in declarations. + Such declaration is referenced as the target declaration below. + +
    • + The target declaration must have value being component value list, + and target declaration's important flag must be + set if important flag is set, and unset otherwise. + +
    • + Any CSS declaration which is not the target declaration must not be changed, inserted, + or removed from declarations. + +
    • + If there are CSS declarations in declarations whose + property name is in the same logical property group as + property, but has a different logical kind, target declaration must be + at an index after all of those CSS declarations. + +
    • + The steps must return true if the serialization of declarations was changed as result + of the steps. It may return false otherwise. +
    + +Issue: Should we add something like "Any observable side effect must not be made outside +declarations"? The current constraints sound like a hole for undefined behavior. + +Note: The steps of set a CSS declaration are not defined in this level of CSSOM. The user agent may +use different algorithm as far as the constraints above hold. + +
    + The simplest way to conform with the constraints would be to always remove any existing declaration + matching property, and append the new declaration to the end. But based on implementation + feedback, this approach would likely regress performance. + + Another possible algorithm is: +
      +
    1. If property is a case-sensitive match for a property name + of a CSS declaration in declarations, follow these substeps: +
        +
      1. Let target declaration be such CSS declaration. +
      2. Let needs append be false. +
      3. For each declaration in declarations after + target declaration: +
          +
        1. If declaration's property name is not in the same + logical property group as property, then continue. +
        2. If declaration' property name has the same + logical kind as property, then continue. +
        3. Let needs append be true. +
        4. Break. +
        +
      4. If needs append is false, then: +
          +
        1. Let needs update be false. +
        2. If target declaration's value is not equal to component + value list, then let needs update be true. +
        3. If target declaration's important flag is not equal to + whether important flag is set, then let needs update be true. +
        4. If needs update is false, then return false. +
        5. Set target declaration's value to component value list. +
        6. If important flag is set, then set target declaration's + important flag, otherwise unset it. +
        7. Return true. +
        +
      5. Otherwise, remove target declaration from declarations. +
      +
    2. Append a new CSS declaration with property name property, + value component value list, and important flag + set if important flag is set to declarations. +
    3. Return true. +
    +
    The removeProperty(property) method must run these steps: