Skip to content

dayjs(null) throws error, not return dayjs object as invalid date #2095

@inqbs

Description

@inqbs

Describe the bug
dayjs(null) is throws error, 'Uncaught TypeError: can't access property "constructor", n is null'.
It says that error occured on dayjs/plugin/objectSupport.js

11:11:19.151 objectSupport.js:1 Uncaught TypeError: Cannot read properties of null (reading 'constructor')
    at M.r (objectSupport.js:1:412)
    at i.parse (objectSupport.js:1:887)
    at e.parse (preParsePostFormat.js:1:447)
    at u.parse (utc.js:1:692)
    at new M (dayjs.min.js:1:2038)
    at w (dayjs.min.js:1:1869)
    at <anonymous>:1:1
r @ objectSupport.js:1
i.parse @ objectSupport.js:1
e.parse @ preParsePostFormat.js:1
u.parse @ utc.js:1
M @ dayjs.min.js:1
w @ dayjs.min.js:1

Expected behavior
It should be return dayjs object with invalid date. (it means, dayjs(null).isValid() return false correctly.)

Information

  • Day.js Version: v1.11.6
  • OS: Windows 10
  • Browser: Firefox latest version
  • Time zone: GMT+09:00
  • Used Plugins:
    • customParseFormat
    • duration
    • isoWeek
    • isSameOrBefore
    • objectSupport

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions