New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Need access to the component's host CSSStyleDeclaration via this.style. #3999
Comments
Hi @nolanlawson and everyone, I'm trying to work on this issue, I've worked with LWC before but it's the first time I'm trying to contribute here. Could anyone guide me about how I would go about this? |
Thanks for your interest @le-incroyable1-dev! I'd recommend looking at how we implemented This was a similar scenario where we were just missing a mapping from |
@le-incroyable1-dev Any new API added to the |
@nolanlawson thanks for all the help. I've raised a PR for this, please get it reviewed and let me know about any problems! |
No longer up-for-grabs since this is slated for the v7 release ^ |
Description
This is more common with Light DOM components but is something that can happen with Shadow DOM components depending on how you try to access the host's CSSStyleDeclaration.
I noticed that when using Shadow DOM components, I could do things like add custom CSS properties to the host by doing something like:
It seemed natural to be able to do something similar for Light DOM components like:
However I found that
this.style
is always undefined in the Light DOM component. This is also preventing me from being able to get the value of a custom CSS property:Steps to Reproduce
This playground helps reproduce the issue:
https://stackblitz.com/edit/salesforce-lwc-ndqrwq?file=src%2Fmodules%2Fx%2Fapp%2Fapp.html
It also includes a suggested workaround which is to get to the host element via
refs
orchildren
:This will only work after
renderedCallback
.Expected Results
We should be able to access the host's CSSStyleDeclaration via
this.style
.Actual Results
The value of
this.style
is always undefined.Browsers Affected
All
Version
Possible Solution
Additional context/Screenshots
The text was updated successfully, but these errors were encountered: