Skip to content

Commit 1314b18

Browse files
authored
Merge pull request #1630 from jd-opensource/feat_enhui_fix
fix: defined by class are hung on the prototype, and enumerable is fa…
2 parents c282bac + 7d1a815 commit 1314b18

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/sandbox/request.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export function createMicroFetch (url: string, target?: Window['fetch']): Window
4747
export function createMicroXMLHttpRequest (url: string, target?: XMLHttpRequest): any {
4848
const rawXMLHttpRequest = !isUndefined(target) ? target : globalEnv.rawWindow.XMLHttpRequest
4949
if (!isConstructor(rawXMLHttpRequest)) return rawXMLHttpRequest
50-
return class MicroXMLHttpRequest extends rawXMLHttpRequest {
50+
class MicroXMLHttpRequest extends rawXMLHttpRequest {
5151
open (method: string, reqUrl: string, ...rests: unknown[]): void {
5252
if ((isString(reqUrl) && !/^f(ile|tp):\/\//.test(reqUrl)) || isURL(reqUrl)) {
5353
reqUrl = createURL(reqUrl, url).toString()
@@ -56,6 +56,9 @@ export function createMicroXMLHttpRequest (url: string, target?: XMLHttpRequest)
5656
super.open(method, reqUrl, ...rests)
5757
}
5858
}
59+
// The methods defined by class are hung on the prototype, and enumerable is false by default
60+
MicroXMLHttpRequest.prototype && Object.defineProperty(MicroXMLHttpRequest.prototype, 'open', { enumerable: true })
61+
return MicroXMLHttpRequest
5962
}
6063

6164
export interface EventSourceInstance {

0 commit comments

Comments
 (0)