Object.updateTree = function updateTree(obj, src) {
if (obj == null) {
obj = {};
}
for (var key in src) {
if (typeof obj[key] == 'object' && typeof src[key] == 'object') {
updateTree(obj[key], src[key]);
} else {
obj[key] = src[key];
}
}
return obj;
};
var elem = Object.updateTree(document.createElement('div'), {
style: {
fontSize: '200%',
cursor: 'pointer'
},
onclick: function() { alert('click!'); },
innerHTML: 'click me'
});
document.body.appendChild(elem);