File tree Expand file tree Collapse file tree 2 files changed +28
-4
lines changed Expand file tree Collapse file tree 2 files changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -330,19 +330,19 @@ export class Svg {
330
330
}
331
331
332
332
/**
333
- * Get element height using `getBoundingClientRect `
333
+ * Get element height using `clientHeight `
334
334
* @return The elements height in pixels
335
335
*/
336
336
height ( ) {
337
- return this . _node . getBoundingClientRect ( ) . height ;
337
+ return this . _node . clientHeight ;
338
338
}
339
339
340
340
/**
341
- * Get element width using `getBoundingClientRect `
341
+ * Get element width using `clientWidth `
342
342
* @return The elements width in pixels
343
343
*/
344
344
width ( ) {
345
- return this . _node . getBoundingClientRect ( ) . width ;
345
+ return this . _node . clientWidth ;
346
346
}
347
347
348
348
/**
Original file line number Diff line number Diff line change @@ -42,8 +42,32 @@ export function mockDomRects() {
42
42
bottom : 0 ,
43
43
left : 0
44
44
} ) ;
45
+
46
+ Object . defineProperties ( SVGElement . prototype , {
47
+ clientWidth : {
48
+ configurable : true ,
49
+ get : ( ) => 500
50
+ } ,
51
+ clientHeight : {
52
+ configurable : true ,
53
+ get : ( ) => 500
54
+ }
55
+ } ) ;
45
56
}
46
57
47
58
export function destroyMockDomRects ( ) {
48
59
SVGElement . prototype . getBoundingClientRect = getBoundingClientRect ;
60
+
61
+ // Redefine clientWidth and clientHeight properties from the prototype of SVGElement
62
+ const ElementPrototype = Object . getPrototypeOf ( SVGElement . prototype ) ;
63
+ Object . defineProperties ( SVGElement . prototype , {
64
+ clientWidth : Object . getOwnPropertyDescriptor (
65
+ ElementPrototype ,
66
+ 'clientWidth'
67
+ ) ! ,
68
+ clientHeight : Object . getOwnPropertyDescriptor (
69
+ ElementPrototype ,
70
+ 'clientHeight'
71
+ ) !
72
+ } ) ;
49
73
}
You can’t perform that action at this time.
0 commit comments