Skip to content

Object.prototype.toString.call(form) returns "[object Object]" instead of "[object FormData]" #396

Description

@ThisIsMissEm

This appears to be due to a change in the algorithm used for determining the toString of an Object. See step 16 of 19.1.3.6 Object.prototype.toString ( )

const form = new FormData();

assert(form.toString() == "[object FormData]", "toString() results in [object FormData]")
assert(Object.prototype.toString.call(form) == "[object FormData]", "Object.prototype.toString.call(form) results in [object FormData]")

In version 2.3.2 of FormData, the second assertion will fail as Object.prototype.toString.call(form) returns [object Object]

The fix for this is to add support for the toStringTag symbol, like the following:

if (Symbol && Symbol.toStringTag) {
  Object.defineProperty(FormData.prototype, Symbol.toStringTag, {
    value: 'FormData',
    writable: false,
    enumerable: false,
    configurable: true
  });
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions