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

90.91% Statements 10/11
83.33% Branches 5/6
66.67% Functions 2/3
90.91% Lines 10/11
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                            514×     514×                                                 644×     644×     644×    
/*!
 * VisualEditor ContentEditable TableCellableNode class.
 *
 * @copyright 2011-2019 VisualEditor Team and others; see http://ve.mit-license.org
 */
 
/**
 * 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 () {
	var 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 ];
};