mirror of
https://github.com/denoland/deno.git
synced 2024-11-29 16:30:56 -05:00
fix toString for some web objects (#2040)
This commit is contained in:
parent
5f97c041d9
commit
bb617d2478
8 changed files with 37 additions and 0 deletions
|
@ -52,6 +52,10 @@ export class CustomEvent extends event.Event implements domTypes.CustomEvent {
|
||||||
|
|
||||||
customEventAttributes.set(this, { detail });
|
customEventAttributes.set(this, { detail });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get [Symbol.toStringTag](): string {
|
||||||
|
return "CustomEvent";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Built-in objects providing `get` methods for our
|
/** Built-in objects providing `get` methods for our
|
||||||
|
|
|
@ -19,3 +19,9 @@ test(function customEventInitializedWithDetail() {
|
||||||
assertEquals(event.target, null);
|
assertEquals(event.target, null);
|
||||||
assertEquals(event.type, type);
|
assertEquals(event.type, type);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test(function toStringShouldBeWebCompatibility() {
|
||||||
|
const type = "touchstart";
|
||||||
|
const event = new CustomEvent(type, {});
|
||||||
|
assertEquals(event.toString(), "[object CustomEvent]");
|
||||||
|
});
|
||||||
|
|
|
@ -53,4 +53,8 @@ export class EventTarget implements domTypes.EventTarget {
|
||||||
}
|
}
|
||||||
return !event.defaultPrevented;
|
return !event.defaultPrevented;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get [Symbol.toStringTag](): string {
|
||||||
|
return "EventTarget";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,3 +87,8 @@ test(function constructedEventTargetUseObjectPrototype() {
|
||||||
target.dispatchEvent(event);
|
target.dispatchEvent(event);
|
||||||
assertEquals(callCount, 2);
|
assertEquals(callCount, 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test(function toStringShouldBeWebCompatibility() {
|
||||||
|
const target = new EventTarget();
|
||||||
|
assertEquals(target.toString(), "[object EventTarget]");
|
||||||
|
});
|
||||||
|
|
|
@ -136,6 +136,10 @@ class FormDataBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get [Symbol.toStringTag](): string {
|
||||||
|
return "FormData";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class FormData extends DomIterableMixin<
|
export class FormData extends DomIterableMixin<
|
||||||
|
|
|
@ -166,3 +166,8 @@ test(function formDataParamsArgumentsCheck() {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test(function toStringShouldBeWebCompatibility() {
|
||||||
|
const formData = new FormData();
|
||||||
|
assertEquals(formData.toString(), "[object FormData]");
|
||||||
|
});
|
||||||
|
|
|
@ -125,6 +125,10 @@ class HeadersBase {
|
||||||
this._validateValue(newvalue);
|
this._validateValue(newvalue);
|
||||||
this[headerMap].set(newname, newvalue);
|
this[headerMap].set(newname, newvalue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get [Symbol.toStringTag](): string {
|
||||||
|
return "Headers";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @internal
|
// @internal
|
||||||
|
|
|
@ -316,3 +316,8 @@ test(function headerParamsArgumentsCheck() {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test(function toStringShouldBeWebCompatibility() {
|
||||||
|
const headers = new Headers();
|
||||||
|
assertEquals(headers.toString(), "[object Headers]");
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in a new issue