@@ -10,9 +10,6 @@ export namespace config {
10
10
11
11
type NativeEvent = Event ;
12
12
13
- /* A JQuery-like object */
14
- type Dom = any ;
15
-
16
13
export namespace dia {
17
14
18
15
type Event = mvc . TriggeredEvent ;
@@ -755,13 +752,13 @@ export namespace dia {
755
752
756
753
presentationAttributes ( ) : CellView . PresentationAttributes ;
757
754
758
- highlight ( el ?: SVGElement | Dom | string , opt ?: { [ key : string ] : any } ) : this;
755
+ highlight ( el ?: mvc . $ SVGElement, opt ?: { [ key : string ] : any } ) : this;
759
756
760
- unhighlight ( el ?: SVGElement | Dom | string , opt ?: { [ key : string ] : any } ) : this;
757
+ unhighlight ( el ?: mvc . $ SVGElement, opt ?: { [ key : string ] : any } ) : this;
761
758
762
759
can ( feature : string ) : boolean ;
763
760
764
- findMagnet ( el : SVGElement | Dom | string ) : SVGElement | undefined ;
761
+ findMagnet ( el : mvc . $ SVGElement) : SVGElement | undefined ;
765
762
766
763
findNode ( selector : string ) : SVGElement | HTMLElement | null ;
767
764
@@ -821,7 +818,7 @@ export namespace dia {
821
818
822
819
isDefaultInteractionPrevented ( evt : dia . Event ) : boolean ;
823
820
824
- protected findBySelector ( selector : string , root ?: SVGElement | Dom | string ) : SVGElement [ ] ;
821
+ protected findBySelector ( selector : string , root ?: SVGElement ) : SVGElement [ ] ;
825
822
826
823
protected removeHighlighters ( ) : void ;
827
824
@@ -1499,7 +1496,7 @@ export namespace dia {
1499
1496
1500
1497
getContentBBox ( opt ?: { useModelGeometry : boolean } ) : g . Rect ;
1501
1498
1502
- findView < T extends ElementView | LinkView > ( element : string | Dom | SVGElement ) : T ;
1499
+ findView < T extends ElementView | LinkView > ( element : mvc . $ SVGElement) : T ;
1503
1500
1504
1501
findViewByModel < T extends ElementView | LinkView > ( model : Cell | Cell . ID ) : T ;
1505
1502
@@ -2430,7 +2427,7 @@ export namespace util {
2430
2427
export function getElementBBox ( el : Element ) : dia . BBox ;
2431
2428
2432
2429
export function sortElements (
2433
- elements : Element [ ] | string | Dom ,
2430
+ elements : mvc . $ Element,
2434
2431
comparator : ( a : Element , b : Element ) => number
2435
2432
) : Element [ ] ;
2436
2433
@@ -2773,6 +2770,13 @@ export namespace layout {
2773
2770
2774
2771
export namespace mvc {
2775
2772
2773
+ type Dom = unknown ;
2774
+ // The following types represent the DOM elements that can be passed to the
2775
+ // $() function.
2776
+ type $Element < T extends Element = Element > = string | T | T [ ] | Dom ;
2777
+ type $HTMLElement = $Element < HTMLElement > ;
2778
+ type $SVGElement = $Element < SVGElement > ;
2779
+
2776
2780
interface Event {
2777
2781
// Event
2778
2782
bubbles : boolean | undefined ;
@@ -3160,7 +3164,7 @@ export namespace mvc {
3160
3164
model ?: TModel | undefined ;
3161
3165
// TODO: quickfix, this can't be fixed easy. The collection does not need to have the same model as the parent view.
3162
3166
collection ?: Collection < any > | undefined ; // was: Collection<TModel>;
3163
- el ?: TElement | Dom | string | undefined ;
3167
+ el ?: $Element < TElement > | string | undefined ;
3164
3168
id ?: string | undefined ;
3165
3169
attributes ?: Record < string , any > | undefined ;
3166
3170
className ?: string | undefined ;
@@ -3196,7 +3200,7 @@ export namespace mvc {
3196
3200
// A conditional type used here to prevent `TS2532: Object is possibly 'undefined'`
3197
3201
model : TModel extends Model ? TModel : undefined ;
3198
3202
collection : Collection < any > ;
3199
- setElement ( element : TElement | Dom ) : this;
3203
+ setElement ( element : $Element < TElement > ) : this;
3200
3204
id ?: string | undefined ;
3201
3205
cid : string ;
3202
3206
className ?: string | undefined ;
@@ -3216,7 +3220,7 @@ export namespace mvc {
3216
3220
undelegate ( eventName : string , selector ?: string , listener ?: ViewBaseEventListener ) : this;
3217
3221
3218
3222
protected _removeElement ( ) : void ;
3219
- protected _setElement ( el : TElement | Dom ) : void ;
3223
+ protected _setElement ( el : $Element < TElement > ) : void ;
3220
3224
protected _createElement ( tagName : string ) : void ;
3221
3225
protected _ensureElement ( ) : void ;
3222
3226
protected _setAttributes ( attributes : Record < string , any > ) : void ;
0 commit comments