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

Not deleting attributes.className. #36

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Not deleting attributes.className. #36

wants to merge 2 commits into from

Conversation

saboya
Copy link
Contributor

@saboya saboya commented Feb 27, 2017

Hi. I came across an issue that, if I use className, when the preact components re-renders, the class attributes in my elements are lost. If I use "class", everything just works. I realize that preact recommends class over className, but since className was supposed to work as well (at least according to preactjs/preact#103), I'd consider this a bug.

This is a simple change, but I imagine this code is here for a reason.

Thanks in advance!

@@ -25,7 +25,6 @@ function extend(base, props) {

function setClass(attributes, value, append) {
let cl = getClass(attributes);
if (attributes.className) delete attributes.className;
Copy link
Owner

Choose a reason for hiding this comment

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

Not sure if this will mess up rendering. Likely will render class twice (since its aliased)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From my tests, here's what happens (post-patch):

If only className is set, works as intended (class rendered once, correctly).
If only class is set, works as intended (class rendered once, correctly)
If both class and className are set, class is ignored and className is rendered correctly (as the class attribute).

Copy link
Owner

@developit developit Feb 27, 2017

Choose a reason for hiding this comment

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

just wondering if it overwrites preact-mdl's class modifications. I can set up a test if needed, could just be this test but with added class and className variants to verify that the MDL button classes still make it out to the DOM:
https://github.com/developit/preact-mdl/blob/master/test/index.js#L27

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.

None yet

2 participants