@testing-library/user-event 14.2.3 → 14.2.4
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.
- package/dist/index.cjs +49 -47
- package/dist/index.mjs +49 -47
- package/dist/types/utils/dataTransfer/FileList.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -69,7 +69,7 @@ function readBlobText(blob, FileReader) {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
// src/utils/dataTransfer/FileList.ts
|
|
72
|
-
function createFileList(files) {
|
|
72
|
+
function createFileList(window, files) {
|
|
73
73
|
const list = {
|
|
74
74
|
...files,
|
|
75
75
|
length: files.length,
|
|
@@ -80,8 +80,8 @@ function createFileList(files) {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
};
|
|
83
|
-
list.constructor = FileList;
|
|
84
|
-
Object.setPrototypeOf(list, FileList.prototype);
|
|
83
|
+
list.constructor = window.FileList;
|
|
84
|
+
Object.setPrototypeOf(list, window.FileList.prototype);
|
|
85
85
|
Object.freeze(list);
|
|
86
86
|
return list;
|
|
87
87
|
}
|
|
@@ -133,56 +133,58 @@ function getTypeMatcher(type3, exact) {
|
|
|
133
133
|
return exact ? item.type === (isGroup ? group : type3) : isGroup ? item.type.startsWith(`${group}/`) : item.type === group;
|
|
134
134
|
};
|
|
135
135
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
getData(format) {
|
|
144
|
-
var _a;
|
|
145
|
-
const match = (_a = this.items.find(getTypeMatcher(format, true))) != null ? _a : this.items.find(getTypeMatcher(format, false));
|
|
146
|
-
let text = "";
|
|
147
|
-
match == null ? void 0 : match.getAsString((t) => {
|
|
148
|
-
text = t;
|
|
149
|
-
});
|
|
150
|
-
return text;
|
|
151
|
-
}
|
|
152
|
-
setData(format, data) {
|
|
153
|
-
const matchIndex = this.items.findIndex(getTypeMatcher(format, true));
|
|
154
|
-
const item = new DataTransferItemStub(data, format);
|
|
155
|
-
if (matchIndex >= 0) {
|
|
156
|
-
this.items.splice(matchIndex, 1, item);
|
|
157
|
-
} else {
|
|
158
|
-
this.items.push(item);
|
|
136
|
+
function createDataTransferStub(window) {
|
|
137
|
+
return new class DataTransferStub {
|
|
138
|
+
constructor() {
|
|
139
|
+
this.dropEffect = "none";
|
|
140
|
+
this.effectAllowed = "uninitialized";
|
|
141
|
+
this.items = new DataTransferItemListStub();
|
|
142
|
+
this.files = createFileList(window, []);
|
|
159
143
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
144
|
+
getData(format) {
|
|
145
|
+
var _a;
|
|
146
|
+
const match = (_a = this.items.find(getTypeMatcher(format, true))) != null ? _a : this.items.find(getTypeMatcher(format, false));
|
|
147
|
+
let text = "";
|
|
148
|
+
match == null ? void 0 : match.getAsString((t) => {
|
|
149
|
+
text = t;
|
|
150
|
+
});
|
|
151
|
+
return text;
|
|
152
|
+
}
|
|
153
|
+
setData(format, data) {
|
|
163
154
|
const matchIndex = this.items.findIndex(getTypeMatcher(format, true));
|
|
155
|
+
const item = new DataTransferItemStub(data, format);
|
|
164
156
|
if (matchIndex >= 0) {
|
|
165
|
-
this.items.
|
|
157
|
+
this.items.splice(matchIndex, 1, item);
|
|
158
|
+
} else {
|
|
159
|
+
this.items.push(item);
|
|
166
160
|
}
|
|
167
|
-
} else {
|
|
168
|
-
this.items.clear();
|
|
169
161
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
162
|
+
clearData(format) {
|
|
163
|
+
if (format) {
|
|
164
|
+
const matchIndex = this.items.findIndex(getTypeMatcher(format, true));
|
|
165
|
+
if (matchIndex >= 0) {
|
|
166
|
+
this.items.remove(matchIndex);
|
|
167
|
+
}
|
|
168
|
+
} else {
|
|
169
|
+
this.items.clear();
|
|
170
|
+
}
|
|
175
171
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
172
|
+
get types() {
|
|
173
|
+
const t = [];
|
|
174
|
+
if (this.files.length) {
|
|
175
|
+
t.push("Files");
|
|
176
|
+
}
|
|
177
|
+
this.items.forEach((i) => t.push(i.type));
|
|
178
|
+
Object.freeze(t);
|
|
179
|
+
return t;
|
|
180
|
+
}
|
|
181
|
+
setDragImage() {
|
|
182
|
+
}
|
|
183
|
+
}();
|
|
184
|
+
}
|
|
183
185
|
function createDataTransfer(window, files = []) {
|
|
184
|
-
const dt = typeof window.DataTransfer === "undefined" ?
|
|
185
|
-
Object.defineProperty(dt, "files", { get: () => createFileList(files) });
|
|
186
|
+
const dt = typeof window.DataTransfer === "undefined" ? createDataTransferStub(window) : new window.DataTransfer();
|
|
187
|
+
Object.defineProperty(dt, "files", { get: () => createFileList(window, files) });
|
|
186
188
|
return dt;
|
|
187
189
|
}
|
|
188
190
|
function getBlobFromDataTransferItem(window, item) {
|
|
@@ -2879,7 +2881,7 @@ async function upload(element, fileOrFiles) {
|
|
|
2879
2881
|
})) {
|
|
2880
2882
|
return;
|
|
2881
2883
|
}
|
|
2882
|
-
setFiles(input2, createFileList(files));
|
|
2884
|
+
setFiles(input2, createFileList(getWindow(element), files));
|
|
2883
2885
|
this.dispatchUIEvent(input2, "input");
|
|
2884
2886
|
this.dispatchUIEvent(input2, "change");
|
|
2885
2887
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -87,7 +87,7 @@ function readBlobText(blob, FileReader) {
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
// src/utils/dataTransfer/FileList.ts
|
|
90
|
-
function createFileList(files) {
|
|
90
|
+
function createFileList(window, files) {
|
|
91
91
|
const list = __spreadProps(__spreadValues({}, files), {
|
|
92
92
|
length: files.length,
|
|
93
93
|
item: (index) => list[index],
|
|
@@ -97,8 +97,8 @@ function createFileList(files) {
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
});
|
|
100
|
-
list.constructor = FileList;
|
|
101
|
-
Object.setPrototypeOf(list, FileList.prototype);
|
|
100
|
+
list.constructor = window.FileList;
|
|
101
|
+
Object.setPrototypeOf(list, window.FileList.prototype);
|
|
102
102
|
Object.freeze(list);
|
|
103
103
|
return list;
|
|
104
104
|
}
|
|
@@ -150,56 +150,58 @@ function getTypeMatcher(type3, exact) {
|
|
|
150
150
|
return exact ? item.type === (isGroup ? group : type3) : isGroup ? item.type.startsWith(`${group}/`) : item.type === group;
|
|
151
151
|
};
|
|
152
152
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
getData(format) {
|
|
161
|
-
var _a;
|
|
162
|
-
const match = (_a = this.items.find(getTypeMatcher(format, true))) != null ? _a : this.items.find(getTypeMatcher(format, false));
|
|
163
|
-
let text = "";
|
|
164
|
-
match == null ? void 0 : match.getAsString((t) => {
|
|
165
|
-
text = t;
|
|
166
|
-
});
|
|
167
|
-
return text;
|
|
168
|
-
}
|
|
169
|
-
setData(format, data) {
|
|
170
|
-
const matchIndex = this.items.findIndex(getTypeMatcher(format, true));
|
|
171
|
-
const item = new DataTransferItemStub(data, format);
|
|
172
|
-
if (matchIndex >= 0) {
|
|
173
|
-
this.items.splice(matchIndex, 1, item);
|
|
174
|
-
} else {
|
|
175
|
-
this.items.push(item);
|
|
153
|
+
function createDataTransferStub(window) {
|
|
154
|
+
return new class DataTransferStub {
|
|
155
|
+
constructor() {
|
|
156
|
+
this.dropEffect = "none";
|
|
157
|
+
this.effectAllowed = "uninitialized";
|
|
158
|
+
this.items = new DataTransferItemListStub();
|
|
159
|
+
this.files = createFileList(window, []);
|
|
176
160
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
161
|
+
getData(format) {
|
|
162
|
+
var _a;
|
|
163
|
+
const match = (_a = this.items.find(getTypeMatcher(format, true))) != null ? _a : this.items.find(getTypeMatcher(format, false));
|
|
164
|
+
let text = "";
|
|
165
|
+
match == null ? void 0 : match.getAsString((t) => {
|
|
166
|
+
text = t;
|
|
167
|
+
});
|
|
168
|
+
return text;
|
|
169
|
+
}
|
|
170
|
+
setData(format, data) {
|
|
180
171
|
const matchIndex = this.items.findIndex(getTypeMatcher(format, true));
|
|
172
|
+
const item = new DataTransferItemStub(data, format);
|
|
181
173
|
if (matchIndex >= 0) {
|
|
182
|
-
this.items.
|
|
174
|
+
this.items.splice(matchIndex, 1, item);
|
|
175
|
+
} else {
|
|
176
|
+
this.items.push(item);
|
|
183
177
|
}
|
|
184
|
-
} else {
|
|
185
|
-
this.items.clear();
|
|
186
178
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
179
|
+
clearData(format) {
|
|
180
|
+
if (format) {
|
|
181
|
+
const matchIndex = this.items.findIndex(getTypeMatcher(format, true));
|
|
182
|
+
if (matchIndex >= 0) {
|
|
183
|
+
this.items.remove(matchIndex);
|
|
184
|
+
}
|
|
185
|
+
} else {
|
|
186
|
+
this.items.clear();
|
|
187
|
+
}
|
|
192
188
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
189
|
+
get types() {
|
|
190
|
+
const t = [];
|
|
191
|
+
if (this.files.length) {
|
|
192
|
+
t.push("Files");
|
|
193
|
+
}
|
|
194
|
+
this.items.forEach((i) => t.push(i.type));
|
|
195
|
+
Object.freeze(t);
|
|
196
|
+
return t;
|
|
197
|
+
}
|
|
198
|
+
setDragImage() {
|
|
199
|
+
}
|
|
200
|
+
}();
|
|
201
|
+
}
|
|
200
202
|
function createDataTransfer(window, files = []) {
|
|
201
|
-
const dt = typeof window.DataTransfer === "undefined" ?
|
|
202
|
-
Object.defineProperty(dt, "files", { get: () => createFileList(files) });
|
|
203
|
+
const dt = typeof window.DataTransfer === "undefined" ? createDataTransferStub(window) : new window.DataTransfer();
|
|
204
|
+
Object.defineProperty(dt, "files", { get: () => createFileList(window, files) });
|
|
203
205
|
return dt;
|
|
204
206
|
}
|
|
205
207
|
function getBlobFromDataTransferItem(window, item) {
|
|
@@ -2928,7 +2930,7 @@ function upload(element, fileOrFiles) {
|
|
|
2928
2930
|
})) {
|
|
2929
2931
|
return;
|
|
2930
2932
|
}
|
|
2931
|
-
setFiles(input2, createFileList(files));
|
|
2933
|
+
setFiles(input2, createFileList(getWindow(element), files));
|
|
2932
2934
|
this.dispatchUIEvent(input2, "input");
|
|
2933
2935
|
this.dispatchUIEvent(input2, "change");
|
|
2934
2936
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function createFileList(files: File[]): FileList;
|
|
1
|
+
export declare function createFileList(window: Window & typeof globalThis, files: File[]): FileList;
|