Skip to content

Instantly share code, notes, and snippets.

@trueadm
Last active January 29, 2016 21:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trueadm/a7df3e6129178cc4d60c to your computer and use it in GitHub Desktop.
Save trueadm/a7df3e6129178cc4d60c to your computer and use it in GitHub Desktop.
var t1 = Inferno.createTemplate(function(key, children) {
return {
dom: null,
static: null,
tag: null,
key: key,
attrs: null,
children: children,
nextItem: null
}
}, {
dom: null,
static: null,
tag: 'div',
key: null,
attrs: null,
children: null,
nextItem: null
});
var t2 = Inferno.createTemplate(function(key) {
return {
dom: null,
static: null,
tag: null,
key: key,
attrs: null,
children: key,
nextItem: null
}
}, {
dom: null,
static: null,
tag: 'span',
key: null,
attrs: null,
children: null,
nextItem: null
});
function renderTree(nodes) {
var children = new Array(nodes.length);
var i;
var n;
for (i = 0; i < nodes.length; i++) {
n = nodes[i];
if (n.children !== null) {
children[i] = t1(n.key, renderTree(n.children));
} else {
children[i] = t2(n.key);
}
}
return children;
}
function BenchmarkImpl(container, a, b) {
this.container = container;
this.a = a;
this.b = b;
}
BenchmarkImpl.prototype.setUp = function() {
};
BenchmarkImpl.prototype.tearDown = function() {
Inferno.render(null, this.container);
};
BenchmarkImpl.prototype.render = function() {
Inferno.render(t1(null, renderTree(this.a)), this.container)
};
BenchmarkImpl.prototype.update = function() {
Inferno.render(t1(null, renderTree(this.b)), this.container);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment