Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Feature idea: easy classNames #6

Copy link
Copy link

Description

@staltz
Issue body actions

One feature I like in hyperscript is the ability to easily write the className using CSS selectors:

h('div.foo'), not h('div', {className: 'foo'}).

In Cycle.js, it's also convenient to have the . dot there, because later the classes are used in selectors, e.g. DOM.select('.foo').events('click'). So it's not great if sometimes you need the dot, and sometimes you don't (in className), that's why I like hyperscript keeping it consistent.

Proposal:
How about allowing a string parameter to the hyperscript helper? If the first parameter is a string, then it's interpreted as the selector, so its classes will be parsed out in hyperscript. If the first parameter is an object, we know its the properties object.

E.g.
div('.foo') instead of div({className: 'foo'}).

Of course one would be able to still provide properties and children:

div('.foo', {'data-id': 'headline-6.1.2'}, [
  img({src: user.avatar})
])
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.