MCPcopy Create free account
hub / github.com/alibaba/lowcode-engine / getMockElement

Function getMockElement

packages/designer/tests/utils/bom.ts:81–111  ·  view source on GitHub ↗
(tagName, options = {})

Source from the content-addressed store, hash-verified

79}
80
81export function getMockElement(tagName, options = {}) {
82 const elem = document.createElement(tagName);
83 let {
84 width = 0,
85 height = 0,
86 top = 0,
87 bottom = 0,
88 left = 0,
89 right = 0,
90 } = options;
91 elem.getBoundingClientRect = () => {
92 return {
93 width,
94 height,
95 top,
96 bottom,
97 left,
98 right,
99 };
100 };
101 elem.setWidth = (newWidth) => {
102 width = newWidth;
103 };
104 elem.setHeight = (newHeight) => {
105 height = newHeight;
106 };
107 // console.log(elem.ownerDocument);
108 // elem.ownerDocument = document;
109 // elem.ownerDocument.defaultView = window;
110 return elem;
111}

Callers 2

viewport.test.tsFile · 0.90
location.test.tsFile · 0.90

Calls 1

createElementMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…