Skip to content

Instantly share code, notes, and snippets.

@fgnass
Created July 20, 2016 08:53
Show Gist options
  • Save fgnass/baf9eb9d75025987dfd20fdb1ec85ce9 to your computer and use it in GitHub Desktop.
Save fgnass/baf9eb9d75025987dfd20fdb1ec85ce9 to your computer and use it in GitHub Desktop.
Ideas for JSSX

JSSX

Ideas for https://github.com/fgnass/jssx

Attribute or class?

Currently JSSX follows a simple rule to decide whether a prop is class name or a regular HTML attribute:

For any given prop, if a JSS class with the same name exits, it is interpreted as className, otherwise as attribute.

Given that implementation you should not use classes that would also be valid HTML attributes. A safe and simple way to achieve this is to add a prefix like _ to your class names:

<div _button _disabled={true}>

Alternative Implementation

An alternative approach would be this: Only props starting with a certain prefix are interpreted as classes, all others are attributes. When looking up the actual class, the prefix is stripped:

<div $button $disabled={true} />

Getting rid of DIVs

This would also allow us to introduce the following shortcut:

<$foo>
  <$bar />
</$foo>

... which would translate into:

<div $foo>
  <div $bar />
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment