Files
SIA/tools/itb/js/dom_analyzer.js.patch
2025-01-16 14:36:37 +01:00

179 lines
4.0 KiB
Diff

136,137c136,137
< // Get element base info
< const elementInfo = {
---
> // Get element base info
> const elementInfo = {
140c140
< y: Math.round(isFixed ? rect.top : rect.top + window.pageYOffset),
---
> y: Math.round(isFixed ? rect.top : rect.top + window.pageYOffset),
141c141
< width: Math.round(rect.width),
---
> width: Math.round(rect.width),
142c142
< height: Math.round(rect.height),
---
> height: Math.round(rect.height),
143c143
< interactions: [],
---
> interactions: [],
144c144
< fixed: isFixed
---
> fixed: isFixed
148c148
< if (isClickable(element) || isInputElement(element)) {
---
> if (isClickable(element) || isInputElement(element)) {
150c150
< const id = element.id;
---
> const id = element.id;
151c151
< if (id) {
---
> if (id) {
152c152
< elementInfo.id = id;
---
> elementInfo.id = id;
153c153
< } else {
---
> } else {
154c154
< // Only add suggested click if there's no ID
---
> // Only add suggested click if there's no ID
155c155
< elementInfo.suggestedClick = {
---
> elementInfo.suggestedClick = {
156c156
< x: Math.round(elementInfo.x + elementInfo.width / 2),
---
> x: Math.round(elementInfo.x + elementInfo.width / 2),
157c157
< y: Math.round(elementInfo.y + elementInfo.height / 2)
---
> y: Math.round(elementInfo.y + elementInfo.height / 2)
158c158
< };
---
> };
161c161
< const isInteractive = isClickable(element) || isInputElement(element);
---
> const isInteractive = isClickable(element) || isInputElement(element);
163c163
< if (!isInteractive) {
---
> if (!isInteractive) {
164c164
< elementInfo.text = getElementText(element);
---
> elementInfo.text = getElementText(element);
166c166
< }
---
> }
168c168
< if (isClickable(element)) {
---
> if (isClickable(element)) {
169c169
< elementInfo.interactions.push('click');
---
> elementInfo.interactions.push('click');
170c170
< elementInfo.buttonText = getElementText(element);
---
> elementInfo.buttonText = getElementText(element);
172c172
< }
---
> }
173c173
< if (isInputElement(element)) {
---
> if (isInputElement(element)) {
174c174
< const inputType = element.getAttribute('type') || 'text';
---
> const inputType = element.getAttribute('type') || 'text';
175c175
< elementInfo.interactions.push(`input:${inputType}`);
---
> elementInfo.interactions.push(`input:${inputType}`);
177c177
< const placeholder = element.getAttribute('placeholder');
---
> const placeholder = element.getAttribute('placeholder');
178c178
< if (placeholder) {
---
> if (placeholder) {
179c179
< elementInfo.placeholder = placeholder;
---
> elementInfo.placeholder = placeholder;
180c180
< }
---
> }
182c182
< }
---
> }
183c183
< if (isScrollable(element)) {
---
> if (isScrollable(element)) {
184c184
< elementInfo.interactions.push('scroll');
---
> elementInfo.interactions.push('scroll');
186c186
< }
---
> }
188c188
< if (element.tagName === 'IMG') {
---
> if (element.tagName === 'IMG') {
189c189
< elementInfo.src = element.src;
---
> elementInfo.src = element.src;
190c190
< elementInfo.alt = element.alt;
---
> elementInfo.alt = element.alt;
192c192
< }
---
> }
194c194
< elementInfo.children = Array.from(element.children)
---
> elementInfo.children = Array.from(element.children)
195c195
< .map(child => processElements(child))
---
> .map(child => processElements(child))
196c196
< .flat()
---
> .flat()
197c197
< .filter(child => child !== null);
---
> .filter(child => child !== null);
199c199
< return elementInfo;
---
> return elementInfo;