Last active
September 5, 2015 18:45
-
-
Save clohr/c514d8fd79a0162a2e8f to your computer and use it in GitHub Desktop.
Example using Matt Esch's virtual-dom
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var h = require('virtual-dom/h'); | |
var createElement = require('virtual-dom').create; | |
var BoxHook = function(){}; | |
BoxHook.prototype.hook = function(elem, key, previousValue) { | |
console.log('Hello from ' + elem.id + '!\nMy key was: ' + key); | |
}; | |
var properties = { | |
attributes: { | |
name: 'red-box-name', | |
style: 'width: 100px; height: 100px; background-color: #fff; border: double 4px #000' | |
}, | |
dataset: { 'test': 'testing' }, | |
id: 'my-red-box', | |
'box-hook': new BoxHook() | |
} | |
var txt = 'This is some text'; | |
RedBoxNode = h('div.red.box', properties, [txt], 'my-unique-red-box'); | |
RedBoxElem = createElement(RedBoxNode); | |
document.body.appendChild(RedBoxElem); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment