Polymer / polymer

Our original Web Component library.
https://polymer-library.polymer-project.org/
BSD 3-Clause "New" or "Revised" License
22.05k stars 2.01k forks source link

Doesn't to deserializing string format of Date to Date object #5671

Closed corocoto closed 3 years ago

corocoto commented 3 years ago

Description

I trying to deserialize string format of Date to Date object, but it's still string type.

I thought it was done automatically after reading the #4592 issue. Maybe I understood it somehow differently. And if it is, how can I make it right?

Steps to Reproduce

  1. Declare property currentDate like this:
    static get properties(){
    currentDate : {
        type  : Date,
    value : '2020-08-04T15:08:58.037Z', // ISO format
    },
    }
  2. Add checking inside of connectedCallback:
    connectedCallback(){
    super.connectedCallback();
    console.log(this.currentDate.constructor === Date);
    }

Expected Results

Should display true.

Actual Results

Display false.

Versions

corocoto commented 3 years ago

Ah, sorry. It's my wrong. It will be work if I set string value ('2020-08-04T15:08:58.037Z') as attribute's value.

So it looks like this:

<my-calendar current-date="2020-08-04T15:08:58.037Z"></my-calendar>