@@ -137,10 +137,10 @@ export type SourceLocation = {
137137}
138138
139139export type Rect = {
140- x : number
141- y : number
142- w : number
143- h : number
140+ x : number
141+ y : number
142+ width : number
143+ height : number
144144}
145145
146146/**
@@ -149,10 +149,10 @@ export type Rect = {
149149 */
150150export type ElementInterface < T extends object > = {
151151 isElement : ( obj : object | T ) => obj is T ,
152+ getElementAt : ( e : MouseEvent ) => T | null ,
152153 getName : ( el : T ) => string | null ,
153154 getChildren : ( el : T ) => Iterable < T > ,
154155 getParent : ( el : T ) => T | null ,
155- getElementAt : ( e : MouseEvent ) => T | null ,
156156 getLocation : ( el : T ) => SourceLocation | null ,
157157 getRect : ( el : T ) => Rect | null ,
158158}
@@ -162,18 +162,14 @@ export type ElementInterface<T extends object> = {
162162 */
163163export const dom_element_interface : ElementInterface < Element > = {
164164 isElement : obj => obj instanceof Element ,
165+ getElementAt : e => e . target as Element | null ,
165166 getName : el => el . localName ,
166167 getChildren : el => el . children ,
167168 getParent : el => el . parentElement ,
168- getElementAt : e => e . target as Element | null ,
169+ getRect : el => el . getBoundingClientRect ( ) ,
169170 getLocation : el => {
170171 let attr = locator . getLocationAttr ( el )
171- if ( attr == null ) return null
172- return locator . parseLocationString ( attr ) ?? null
173- } ,
174- getRect : el => {
175- let rect = el . getBoundingClientRect ( )
176- return { x : rect . x , y : rect . y , w : rect . width , h : rect . height }
172+ return attr && locator . parseLocationString ( attr ) || null
177173 } ,
178174}
179175
0 commit comments