All files / src/ce ve.ce.TableCellableNode.js

91.66% Statements 11/12
83.33% Branches 5/6
66.66% Functions 2/3
91.66% Lines 11/12

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                            1x 996x 2x     996x         1x                     1x                     1x 1512x 1512x   1512x     1512x    
/*!
 * VisualEditor ContentEditable TableCellableNode class.
 *
 * @copyright See AUTHORS.txt
 */
 
/**
 * ContentEditable node which can behave as a table cell
 *
 * @class
 *
 * @abstract
 * @constructor
 */
ve.ce.TableCellableNode = function VeCeTableCellableNode() {
	if ( this.isCellable() && !this.isCellEditable() ) {
		this.$element.attr( 'title', ve.msg( 'visualeditor-aliennode-tooltip' ) );
	}
 
	this.$element.addClass( 've-ce-tableCellableNode' );
};
 
/* Inheritance */
 
OO.initClass( ve.ce.TableCellableNode );
 
/* Static Methods */
 
/* Methods */
 
/**
 * Set the editing mode of a table cell node
 *
 * @param {boolean} enable Enable editing
 */
ve.ce.TableCellableNode.prototype.setEditing = function () {
};
 
/**
 * Get the HTML tag name.
 *
 * Tag name is selected based on the model's style attribute.
 *
 * @return {string} HTML tag name
 * @throws {Error} Invalid style
 */
ve.ce.TableCellableNode.prototype.getTagName = function () {
	const style = this.model.getAttribute( 'style' ),
		types = { data: 'td', header: 'th' };
 
	Iif ( !Object.prototype.hasOwnProperty.call( types, style ) ) {
		throw new Error( 'Invalid style' );
	}
	return types[ style ];
};