Skip to content
This repository has been archived by the owner on Sep 14, 2021. It is now read-only.

No getComputedStyleValue on Polymer.Element? #83

Closed
kevinpschaaf opened this issue Apr 3, 2017 · 5 comments
Closed

No getComputedStyleValue on Polymer.Element? #83

kevinpschaaf opened this issue Apr 3, 2017 · 5 comments
Assignees

Comments

@kevinpschaaf
Copy link
Contributor

From @arthurevans on March 4, 2017 2:54

I suspect it's used significantly less frequently that updateStyles(), but it seemed kind of funky to me that we had a facade for updateStyles on Polymer.Element, but not for getComputedStyleValue.

Currently documented solution for this is:

if (ShadyCSS) {
  style = ShadyCSS.getComputedStyleValue('--something');
} else {
  style = getComputedStyle(this, '--something');
}

Which hopefully I got right. If not, it's here:

https://github.com/Polymer/docs/blame/master/app/2.0/docs/devguide/custom-css-properties.md#L361

Copied from original issue: Polymer/polymer#4374

@kevinpschaaf
Copy link
Contributor Author

At one point we discussed patching getComputedStyleValue to make the custom property handling in the shim transparent... @azakus ?

@kevinpschaaf
Copy link
Contributor Author

The plan of record will be for shadycss to patch window.getComputedStyle() to have the return object's getPropertyValue() to return the correct value for custom properties.

Note the correct incantation is the following (note the native syntax in the else clause is what we would shim to work transparently; the syntax is a bit ugly but that's the native API):

if (window.ShadyCSS) {
  style = ShadyCSS.getComputedStyleValue(el, '--something');
} else {
  style = getComputedStyle(el).getPropertyValue('--something');
}

@dfreedm dfreedm added p1 and removed 2.x labels Apr 4, 2017
@jimivdw
Copy link

jimivdw commented Apr 5, 2017

Not sure if I should create a separate issue for this, but it appears that it is also no longer possible to retrieve the value of a CSS mixin using getComputedStyleValue, which was possible before. Is this intended? And is there a different way of retrieving mixin values now?

@dfreedm
Copy link
Contributor

dfreedm commented Apr 6, 2017

@jimivdw that was never supported, and is actually really hard to do with the ApplyShim, as the original --mixin variable is long gone by the time you would try to get the value for it.

@dfreedm
Copy link
Contributor

dfreedm commented Sep 22, 2017

Closing this issue. Polymer has getComputedStyleValue on the Polymer 1.x hybrid elements.

@dfreedm dfreedm closed this as completed Sep 22, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants