All files / src/ce/nodes ve.ce.CommentNode.js

100% Statements 18/18
50% Branches 1/2
100% Functions 4/4
100% Lines 18/18

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82                                  1x   24x     24x     24x     24x         1x 1x       1x   1x   1x             1x 36x                     1x 2x 2x                   1x   3x         1x  
/*!
 * VisualEditor ContentEditable CommentNode class.
 *
 * @copyright See AUTHORS.txt
 */
 
/**
 * ContentEditable comment node.
 *
 * @class
 * @extends ve.ce.LeafNode
 * @mixes ve.ce.FocusableNode
 *
 * @constructor
 * @param {ve.dm.CommentNode} model Model to observe
 * @param {Object} [config] Configuration options
 */
ve.ce.CommentNode = function VeCeCommentNode( model, config ) {
	// Parent constructor
	ve.ce.CommentNode.super.call( this, model, config );
 
	// Mixin constructors
	ve.ce.FocusableNode.call( this, this.$element, config );
 
	// Events
	this.model.connect( this, { attributeChange: 'onAttributeChange' } );
 
	// DOM changes
	this.$element.addClass( 've-ce-commentNode' );
};
 
/* Inheritance */
 
OO.inheritClass( ve.ce.CommentNode, ve.ce.LeafNode );
OO.mixinClass( ve.ce.CommentNode, ve.ce.FocusableNode );
 
/* Static Properties */
 
ve.ce.CommentNode.static.name = 'comment';
 
ve.ce.CommentNode.static.primaryCommandName = 'comment';
 
ve.ce.CommentNode.static.iconWhenInvisible = 'notice';
 
/* Static Methods */
 
/**
 * @inheritdoc
 */
ve.ce.CommentNode.static.getDescription = function ( model ) {
	return model.getAttribute( 'text' );
};
 
/**
 * Update the rendering of the 'text' attribute
 * when it changes in the model.
 *
 * @param {string} key Attribute key
 * @param {string} from Old value
 * @param {string} to New value
 */
ve.ce.CommentNode.prototype.onAttributeChange = function ( key ) {
	Eif ( key === 'text' ) {
		this.updateInvisibleIconLabel();
	}
};
 
/* Method */
 
// eslint-disable-next-line jsdoc/require-returns
/**
 * @see ve.ce.FocusableNode
 */
ve.ce.CommentNode.prototype.hasRendering = function () {
	// Comment nodes never have a rendering, don't bother with expensive DOM inspection
	return false;
};
 
/* Registration */
 
ve.ce.nodeFactory.register( ve.ce.CommentNode );