Skip to content
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

Fix #113 - Add support for CSSStyleDeclaration property get, set, and remove #114

Conversation

MadLittleMods
Copy link
Contributor

@MadLittleMods MadLittleMods commented Feb 12, 2022

Add support for CSSStyleDeclaration property get, set, and remove:

Fix #113

…get, set, and remove

 - CSSStyleDeclaration.getPropertyValue()
 - CSSStyleDeclaration.setProperty()
 - CSSStyleDeclaration.removeProperty()
@@ -82,6 +82,21 @@ class CSSStyleDeclaration extends Map {
refs.get(this).setAttribute('style', value);
}

getPropertyValue(name) {
const self = this[PRIVATE];
Copy link
Contributor Author

@MadLittleMods MadLittleMods Feb 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my own understanding/curiosity, what is the difference between this and this[PRIVATE] (which is a getter that returns this)?

It seems like the cssText getters and setters are the only ones that use this directly.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this points at the proxy, not at the original Map reference ... the constructor returns a Proxy ;-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhh, the proxy passes the this[PRIVATE] getter back to the original object and accesses that this. Thanks for the explanation 🙂

@@ -81,6 +81,21 @@ export class CSSStyleDeclaration extends Map {
refs.get(this).setAttribute('style', value);
}

getPropertyValue(name) {
const self = this[PRIVATE];
return handler.get(self, name);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The handler is for proxy thing ... once you have the original Map that is holding all values, you gotta do like:

return self.get(uhyphen(name));

got it?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, never mind ... updateKeys needs to happen, so this was unnecessary optimization. All good!

@WebReflection WebReflection merged commit b726797 into WebReflection:main Feb 14, 2022
@MadLittleMods
Copy link
Contributor Author

Thanks for the review, merge, and release @WebReflection 🎉

MadLittleMods added a commit to element-hq/hydrogen-web that referenced this pull request Feb 25, 2022
See #653 (comment)

We can allow this to run now since I added support for `setProperty` in `linkedom` ⏩ WebReflection/linkedom#114
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for CSSStyleDeclaration.setProperty() and CSSStyleDeclaration.removeProperty()
2 participants