Skip to content

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

Merged
WebReflection merged 1 commit intoWebReflection:mainfrom
MadLittleMods:113-add-support-for-cssstyledeclaration-property-get-set-remove
Feb 14, 2022
Merged

Fix #113 - Add support for CSSStyleDeclaration property get, set, and remove#114
WebReflection merged 1 commit intoWebReflection:mainfrom
MadLittleMods:113-add-support-for-cssstyledeclaration-property-get-set-remove

Conversation

@MadLittleMods
Copy link
Copy Markdown
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()
}

getPropertyValue(name) {
const self = this[PRIVATE];
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 🙂


getPropertyValue(name) {
const self = this[PRIVATE];
return handler.get(self, name);
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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