`toElement` and extending Element

by rpflorence

HTML

<div id=el>Hi</div>

JavaScript

var ToElemented = new Class({
    
    initialize: function(element){
        this.element = document.id(element);
    },
    
    toElement: function(){
        return this.element;
    }
    
});

var instance = new ToElemented('el');

$(instance).setStyle('font-weight', 'bold');
// same as $('el').setStyle('color', 'red');​​​

Element.implement({
    
    supermanify: function(){
        return this.setStyles({
            'border': 'solid 10px blue',
            'background': 'red',
            'color': 'yellow'
        });
    }
});
    
$(instance).supermanify();