0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-10-29 08:58:01 -04:00

fix toString for some web objects (#2040)

This commit is contained in:
迷渡 2019-04-03 20:41:05 +08:00 committed by Ryan Dahl
parent 5f97c041d9
commit bb617d2478
8 changed files with 37 additions and 0 deletions

View file

@ -52,6 +52,10 @@ export class CustomEvent extends event.Event implements domTypes.CustomEvent {
customEventAttributes.set(this, { detail });
}
get [Symbol.toStringTag](): string {
return "CustomEvent";
}
}
/** Built-in objects providing `get` methods for our

View file

@ -19,3 +19,9 @@ test(function customEventInitializedWithDetail() {
assertEquals(event.target, null);
assertEquals(event.type, type);
});
test(function toStringShouldBeWebCompatibility() {
const type = "touchstart";
const event = new CustomEvent(type, {});
assertEquals(event.toString(), "[object CustomEvent]");
});

View file

@ -53,4 +53,8 @@ export class EventTarget implements domTypes.EventTarget {
}
return !event.defaultPrevented;
}
get [Symbol.toStringTag](): string {
return "EventTarget";
}
}

View file

@ -87,3 +87,8 @@ test(function constructedEventTargetUseObjectPrototype() {
target.dispatchEvent(event);
assertEquals(callCount, 2);
});
test(function toStringShouldBeWebCompatibility() {
const target = new EventTarget();
assertEquals(target.toString(), "[object EventTarget]");
});

View file

@ -136,6 +136,10 @@ class FormDataBase {
}
}
}
get [Symbol.toStringTag](): string {
return "FormData";
}
}
export class FormData extends DomIterableMixin<

View file

@ -166,3 +166,8 @@ test(function formDataParamsArgumentsCheck() {
);
});
});
test(function toStringShouldBeWebCompatibility() {
const formData = new FormData();
assertEquals(formData.toString(), "[object FormData]");
});

View file

@ -125,6 +125,10 @@ class HeadersBase {
this._validateValue(newvalue);
this[headerMap].set(newname, newvalue);
}
get [Symbol.toStringTag](): string {
return "Headers";
}
}
// @internal

View file

@ -316,3 +316,8 @@ test(function headerParamsArgumentsCheck() {
);
});
});
test(function toStringShouldBeWebCompatibility() {
const headers = new Headers();
assertEquals(headers.toString(), "[object Headers]");
});