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

Cast className using toString #2309

Merged
merged 2 commits into from Nov 24, 2018

Conversation

2 participants
@porsager
Copy link
Contributor

porsager commented Nov 24, 2018

Description

When mithril normalizes classNames it now ensures toString is called before concatenating strings. This ensures mithril works like the browser does when setting dom.className =. The browser always calls toString for either dom.classList.add() or dom.className =

Motivation and Context

This makes mithril behave more like the dom, and allows bss (and maybe others) to support casting to a className using a period when doing

m('div' + b('background blue')) => m('div.bssClass')

and not adding a period when doing

m('div', { class: b('background blue') }) => m('div', { class: 'bssClass' })

flems with fixed mithril

flems without fix

How Has This Been Tested?

Added a test to check if toString is called when using className attr.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation change

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have updated docs/change-log.md

@porsager porsager requested a review from pygy as a code owner Nov 24, 2018

@project-bot project-bot bot added this to Needs triage in Triage/bugs Nov 24, 2018

@isiahmeadows
Copy link
Collaborator

isiahmeadows left a comment

LGTM

@isiahmeadows isiahmeadows merged commit 421474c into MithrilJS:next Nov 24, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

Triage/bugs automation moved this from Needs triage to Closed Nov 24, 2018

@isiahmeadows

This comment has been minimized.

Copy link
Collaborator

isiahmeadows commented Nov 24, 2018

This reads more like a bug than anything (hence the quick merge). @porsager If you wouldn't mind, would you like to ensure the rest of the renderer prefers toString over valueOf for coercing to strings?

@porsager

This comment has been minimized.

Copy link
Contributor

porsager commented Nov 24, 2018

Sure thing, I'll try to go through it Monday 😉

@porsager

This comment has been minimized.

Copy link
Contributor

porsager commented Nov 24, 2018

Ok, just went through it, and I don't think there are other places where it matters.

There is some "" + value usage, but that's dom.value, so I don't think that should change..

@isiahmeadows

This comment has been minimized.

Copy link
Collaborator

isiahmeadows commented Nov 25, 2018

Okay, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment