/**  @author Gilles Coomans <gilles.coomans@gmail.com> */

var utils = require('./utils'),
	Emitter = require('./emitter'),
	PureNode = require('./pure-node'),
	openTags = require('./parsers/open-tags');

//_______________________________________________________ VIRTUAL NODE

/**
 * Virtual Node
 * @param {String} tagName the tagName of the virtual node
 */
function Virtual(opt /*tagName, context*/ ) {
	opt = opt || {};
	this.__yVirtual__ = true;
	if (opt.tagName)
		this.tagName = opt.tagName;
	if (opt.nodeValue)
		this.nodeValue = opt.nodeValue;
	PureNode.call(this, opt);
};

Virtual.prototype  = {
	setAttribute: function(name, value) {
		(this.attributes = this.attributes || {})[name] = value;
	},
	removeAttribute: function(name, value) {
		if (!this.attributes)
			return;
		delete this.attributes[name];
	}
};

utils.mergeProto(PureNode.prototype, Virtual.prototype);
utils.mergeProto(Emitter.prototype, Virtual.prototype);

/**
 * Virtual to String output
 * @return {String} the String représentation of Virtual node
 */
Virtual.prototype.toString = function() {
	if (this.tagName === 'textnode')
		return this.nodeValue;
	var node = '<' + this.tagName;
	if (this.id)
		node += ' id="' + this.id + '"';
	for (var a in this.attributes)
		node += ' ' + a + '="' + this.attributes[a] + '"';
	if (this.classes) {
		var classes = Object.keys(this.classes);
		if (classes.length)
			node += ' class="' + classes.join(' ') + '"';
	}
	if (this.childNodes && this.childNodes.length) {
		node += '>';
		for (var j = 0, len = this.childNodes.length; j < len; ++j)
			node += this.childNodes[j].toString();
		node += '</' + this.tagName + '>';
	} else if (this.scriptContent)
		node += '>' + this.scriptContent + '</script>';
	else if (openTags.test(this.tagName))
		node += '>';
	else
		node += ' />';
	return node;
};

Virtual.createElement = function(tagName) {
	return new Virtual({
		tagName: tagName
	});
};

Virtual.createTextNode = function(value) {
	return new Virtual({
		tagName: 'textnode',
		nodeValue: value
	})
};

module.exports = Virtual;

@@ -296,61 +296,242 @@
 e%0A *
- @param %7BString%7D tagName the tagName of the virtual n
+%0A * A minimal mock of DOMElement. It gathers PureNode and Emitter API and add attributes management (add and remove).%0A * %0A * @param %7BObject%7D option (optional) option object : %7B ?tagName:String, ?nodeValue:String %7D + options from PureN
 ode%0A
@@ -999,16 +999,37 @@
 %0A%09%7D%0A%7D;%0A%0A
+// apply inheritance%0A
 utils.me
@@ -1205,9 +1205,9 @@
 repr
-%C3%A9
+e
 sent
@@ -2016,24 +2016,101 @@
 n node;%0A%7D;%0A%0A
+%0A// Virtual Factory : mimic document.createElement but return a virtual node%0A
 Virtual.crea
@@ -2187,24 +2187,101 @@
 me%0A%09%7D);%0A%7D;%0A%0A
+// Virtual Factory : mimic document.createTextNode but return a virtual node%0A
 Virtual.crea

add comment and clean