Unable to set CSSStyleRule.style

Confirmed Issue #12271447 • Assigned to Francois R.

Details

Author
Daniel H.
Created
Jun 7, 2017
Privacy
This issue is public.
Found in
  • Microsoft Edge
  • Safari
Standard affected
CSS Object Model (CSSOM)

Reports
Reported by 1 person

Sign in to watch or report this issue.

Steps to reproduce

This is the edge version of https://bugs.webkit.org/show_bug.cgi?id=164537

Steps to reproduce:

  1. Load testcase https://bugs.webkit.org/attachment.cgi?id=312230
  2. Hit F12 and open the Console
  3. Reload (so you can see the Console.log statements printed by the attachment)

EXPECTED RESULTS:
The final console.log statement should say “After tweaking rule.style: CCC”

ACTUAL RESULTS:
It says BBB instead of CCC (indicating that rule.style assignment failed)

This is about this spec text:
https://drafts.csswg.org/cssom/#the-cssstylerule-interface

The “PutForwards=cssText” in the WebIDL there means that assignments into rule.style should be forwarded to rule.style.cssText (and they should succeed, given valid CSS).

Firefox Nightly 55 & Chrome Dev 60 give EXPECTED RESULTS. (Earlier versions do too, probably; those just happen to be the versions I’ve got handiest)

Edge 15 gives ACTUAL RESULTS.

Attachments

0 attachments

    Comments and activity

    • Based on local testing, this works correctly on the element.style attribute – e.g. this works fine in Edge 15:
      document.documentElement.style = “font-family: CCC”

      So Edge has this implemented correctly for the ElementCSSInlineStyle interface. But not for the CSSStyleRule interface. (In WebKit/Safari10.1, it’s broken in both interfaces, actually – the above document.documentElement.style tweak is rejected there.)

      Here’s the relevant part of the spec for the element.style attribute, I think:
      https://drafts.csswg.org/cssom/#the-elementcssinlinestyle-interface

      interface ElementCSSInlineStyle {
      [SameObject, PutForwards=cssText] readonly attribute CSSStyleDeclaration style;
      };

      And for the CSSStyleRule.style attribute:
      https://drafts.csswg.org/cssom/#the-cssstylerule-interface

      interface CSSStyleRule : CSSRule {
      attribute CSSOMString selectorText;
      [SameObject, PutForwards=cssText] readonly attribute CSSStyleDeclaration style;
      };

      Notice that the WebIDL is the same for these two “style” attributes, so they should be equivalently assignable.

    • Microsoft Edge Team

      Changed Assigned To to “Francois R.”

      Changed Status to “Confirmed”

    • Hey Daniel :)

      Thanks for reporting the issue.

      It so happens I am the person who implemented the style setter on the Element interface one or two releases ago, not because it met our bug bar but because it annoyed me personnally.

      At the point, I had considered also updating the CSS OM idls but ultimately decided not to, to keep my change as small as possible. I am not really supposed to write code ;-)

      I’ll keep this on the backlog to track this work but I do not expect this to get fixed anytime soon, as it just doesn’t break much more than a few browser-implementor-written test cases.

    • Hi Francois! Thanks for

    • Hi Francois! Thanks for the prompt response.

      You might be interested to know that the WebKit folks landed a fix for this yesterday (on https://bugs.webkit.org/show_bug.cgi?id=164537 ), so at this point Edge is the only browser engine affected by this bug.

      Having said that, I share your feeling that this particular quirk (on the CSSStyleRule interface) isn’t likely to cause breakage in much real-world web content. So, backlog + fixed-eventually sounds OK.

    You need to sign in to your Microsoft account to add a comment.

    Sign in