示例#1
0
	this.text = options.template;
};

Text.prototype = {
	detach: detach,

	firstNode () {
		return this.node;
	},

	render () {
		if ( !this.node ) {
			this.node = document.createTextNode( this.text );
		}

		return this.node;
	},

	toString ( escape ) {
		return escape ? escapeHtml( this.text ) : this.text;
	},

	unrender ( shouldDestroy ) {
		if ( shouldDestroy ) {
			return this.detach();
		}
	}
};

export default Text;
示例#2
0
 it('should escape html', () => {
     escapeHtml('<strong>Escape me!</strong>').should.eq('&lt;strong&gt;Escape me!&lt;/strong&gt;');
 });