Open Bug 137687 Opened 22 years ago Updated 2 years ago

Computed CSSDeclarations need to implement GetCssText

Categories

(Core :: DOM: CSS Object Model, defect, P3)

defect

Tracking

()

Webcompat Priority P3

People

(Reporter: bzbarsky, Unassigned)

References

Details

(Whiteboard: [webcompat])

Attachments

(1 file)

nsComputedDOMStyle does not implement GetCssText....
Priority: -- → P5
Target Milestone: --- → Future
Attached patch FixSplinter Review
This was originally part of my fix to spin out the queryable properties into
the static map, but I left it out of that patch and I forgot about it until
now.
So... we need to canonicalize and do shorthands and the like if we do this,
imo.... (though we could land that as a start, I suppose).
No plans to work on this any time in the foreseeable future, so to default owner.
Assignee: bz-vacation → general
Priority: P5 → --
Target Milestone: Future → ---
Assignee: general → nobody
QA Contact: ian → general
QA Contact: general → style-system
Updating title to make this bug slightly easier to find.
Summary: Computed CSSDeclarations need to implement GetCssText → Computed CSSDeclarations need to implement GetCssText / cssText
A fix for this would be very useful. In the meantime, here's how to work around it: https://gist.github.com/johnkpaul/1754808
The attached gist doesn't work, but this does:

function getComputedStyleCssText(element) {
  var style = window.getComputedStyle(element), cssText;
 
  if (style.cssText != "") {
    return style.cssText;
  }
 
  cssText = "";
  for (var i = 0; i < style.length; i++) {
    cssText += style[i] + ": " + style.getPropertyValue(style[i]) + "; ";
  }
  
  return cssText;
}
Depends on: 91370
No longer depends on: 91370
This looks like it's causing web compat issues.  See https://webcompat.com/issues/3822

Xidorn, do you want to try resurrecting the patch here?  Looks to me like Blink doesn't do any interesting shorthand stuff, so maybe we can just get away with the simple and silly implementation...
Flags: needinfo?(xidorn+moz)
Summary: Computed CSSDeclarations need to implement GetCssText / cssText → Computed CSSDeclarations need to implement GetCssText
Thanks Boris for clarifying/unmixing the two issues
Whiteboard: [webcompat]
This is crazy... Why do they need that? Couldn't we contact google and ask them not to do that?

I can work on the patch... but how should the spec say? Edge returns empty string for computed style's cssText as well. Could we just make the spec do this and ask Blink to change their behavior?
Flags: needinfo?(xidorn+moz)
> Why do they need that?

They're trying to copy the computed style of one node to the inline style of another afaict.

> Couldn't we contact google and ask them not to do that?

Karl has.  He asked them to do the getPropertyValue/setPropertyvalue thing.

> but how should the spec say? 

Spec says to do https://drafts.csswg.org/cssom/#serialize-a-css-declaration-block but that's ... complicated and annoying.

> Could we just make the spec do this and ask Blink to change their behavior?

And Safari (they match Blink; presumably this is still WebKit code)?  We could try, but in the meantime Google drive is slow.  :(
Files a spec issue for this: https://github.com/w3c/csswg-drafts/issues/1033

> And Safari (they match Blink; presumably this is still WebKit code)?  We
> could try, but in the meantime Google drive is slow.  :(

The quickest way should be asking Google drive to fix I think....
>(In reply to Xidorn Quan [:xidorn] (UTC+10) from comment #12)
> The quickest way should be asking Google drive to fix I think....

This has been done today. This doesn't guarantee it will be. Some issues are sometimes never fixed, sometimes fixed one year later or more (because of a redesign). Let's give them one week.
Priority: -- → P3

Migrating Webcompat whiteboard priorities to project flags. See bug 1547409.

Webcompat Priority: --- → ?

See bug 1547409. Migrating whiteboard priority tags to program flags.

Webcompat Priority: ? → revisit
Webcompat Priority: revisit → P3
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: