question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Snabbdom uses a hyper-script-like function to build it’s vdoms, but it’s second argument is different. Instead of attributes it’s properties are used by various “modules”;

h('div', {
  props: {title: someString}, // snabbdom/modules/props
  classes: {selected: isSelected}, // snabbdom/modules/class
  on: {click: doSomething}, // snabbdom/modules/eventlisteners
  style: {color: someColor} // snabbdom/modules/style
}, ['children'])

The snabbdom-jsx module handles this using prefixed attributes in JSX:

<div 
  title={someString} 
  class-selected={isSelected} 
  on-click={doSomething} 
  style: {({color: someColor})}
>
  children
</div>

Would it be feasible for hyperx to do this as well?

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:3
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jorgebucarancommented, Jan 29, 2017

@jamen Here is what I ended up with. Essentially:

} else if ("data-hook-" === key.substr(0, 10)) {
    data.hook[key.substr(10)] = value
}

Good luck with Snabby!

0reactions
jamencommented, Jan 31, 2017

An update on this, I’ve made snabby support hooks and various other modules, by using an s-* prefix (similar to v-* in vue).

Example:

snabby`
  <div s-hook:destroy=${fn}>
  </div>
`

// Using `eventlisteners`:
snabby`
  <div s-on:click=${...}>
  </div>
`

Open to suggestion on how to make this look more nice.

Read more comments on GitHub >

github_iconTop Results From Across the Web

snabbdom/snabbdom: A virtual DOM library with focus on ...
Features for doing complex CSS animations. Powerful event listener functionality. Thunks to optimize the diff and patch process even further. JSX support, ...
Read more >
Snabbdom Renderer - ServiceNow Developers
Snabbdom Renderer. The default renderer is a small virtual DOM library that allows component authors to express their component's view as a function...
Read more >
tea-snabbdom / ento / Observable
tea-snabbdom allows you to implement a complex UI within a single Observable cell. It loosely follows the Elm architecture with the help of...
Read more >
snabbdom/snabbdom - Gitter
BTW does Snabbdom support embedding a tree in an element, for example document.body even if ... Any modifications not made by Snabbdom will...
Read more >
Getting Started With Snabbdom - A Virtual DOM Library
Vue.js, for example, was built on top of Snabbdom. In the official GitHub repo, many other libraries and frameworks using Snabbdom under the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found