@auto-wiz/playwright 1.1.1 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/runner.js +19 -17
  2. package/package.json +2 -2
package/dist/runner.js CHANGED
@@ -110,28 +110,30 @@ class PlaywrightFlowRunner {
110
110
  }
111
111
  else {
112
112
  // Default "structure": clean HTML, keep only id, name, text
113
- text = await locator.evaluate((el) => {
113
+ text = await locator.evaluate(function (el) {
114
114
  const clone = el.cloneNode(true);
115
- function cleanElement(element) {
116
- // Remove all attributes except id and name
117
- const attributes = Array.from(element.attributes);
118
- for (const attr of attributes) {
119
- if (!["id", "name"].includes(attr.name)) {
120
- element.removeAttribute(attr.name);
115
+ // 1. Remove SVGs first
116
+ const svgs = clone.querySelectorAll("svg");
117
+ for (const svg of Array.from(svgs)) {
118
+ svg.remove();
119
+ }
120
+ // 2. Clean attributes of all descendants
121
+ const descendants = clone.querySelectorAll("*");
122
+ for (const child of Array.from(descendants)) {
123
+ const attrs = Array.from(child.attributes);
124
+ for (const attr of attrs) {
125
+ if (attr.name !== "id" && attr.name !== "name") {
126
+ child.removeAttribute(attr.name);
121
127
  }
122
128
  }
123
- // DFS for children
124
- for (const child of Array.from(element.children)) {
125
- // Remove SVGs entirely
126
- if (child.tagName.toLowerCase() === "svg") {
127
- child.remove();
128
- }
129
- else {
130
- cleanElement(child);
131
- }
129
+ }
130
+ // 3. Clean attributes of the root element itself
131
+ const rootAttrs = Array.from(clone.attributes);
132
+ for (const attr of rootAttrs) {
133
+ if (attr.name !== "id" && attr.name !== "name") {
134
+ clone.removeAttribute(attr.name);
132
135
  }
133
136
  }
134
- cleanElement(clone);
135
137
  return clone.outerHTML;
136
138
  });
137
139
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@auto-wiz/playwright",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "license": "MIT",
5
5
  "author": "JaeSang",
6
6
  "repository": {
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "playwright": "^1.40.0",
27
- "@auto-wiz/core": "1.1.1"
27
+ "@auto-wiz/core": "1.1.3"
28
28
  },
29
29
  "devDependencies": {
30
30
  "typescript": "^5.0.0",