@@ -35,10 +35,10 @@ type CanvasParams = SharedParams &
3535 * which works by building up from an empty string / by adding characters
3636 * instead of removing them.
3737 */
38- class _TruncationUtils {
39- fullText : SharedParams [ 'fullText' ] ;
40- ellipsis : SharedParams [ 'ellipsis' ] ;
41- availableWidth : SharedParams [ 'availableWidth' ] ;
38+ abstract class _TruncationUtils {
39+ protected fullText : SharedParams [ 'fullText' ] ;
40+ protected ellipsis : SharedParams [ 'ellipsis' ] ;
41+ protected availableWidth : SharedParams [ 'availableWidth' ] ;
4242
4343 constructor ( { fullText, ellipsis, availableWidth } : SharedParams ) {
4444 this . fullText = fullText ;
@@ -49,24 +49,10 @@ class _TruncationUtils {
4949 /**
5050 * Internal measurement utils which will be overridden depending on the
5151 * rendering approach used (e.g. DOM vs Canvas).
52- *
53- * The thrown errors are there to ensure the base instance utils do not
54- * get called standalone in the future, if more extended classes are added
55- * someday (e.g. new shadow DOM tech, or Flash makes a surprise comeback).
56- *
57- * The istanbul code coverage ignores are there because this base class
58- * is not exported and in theory the code should never be reachable.
5952 */
6053
61- /* istanbul ignore next */
62- get textWidth ( ) : number {
63- throw new Error ( 'This function must be superseded by a DOM or Canvas util' ) ;
64- }
65-
66- /* istanbul ignore next */
67- setTextToCheck = ( _ : string ) : void => {
68- throw new Error ( 'This function must be superseded by a DOM or Canvas util' ) ;
69- } ;
54+ abstract textWidth : number ;
55+ abstract setTextToCheck : ( text : string ) => void ;
7056
7157 /**
7258 * Early return checks
0 commit comments