polymer icon indicating copy to clipboard operation
polymer copied to clipboard

Polymer.Base.deserialize for Boolean values

Open chimarcos opened this issue 10 years ago • 1 comments

Description

I was trying to use Polymer.Base.deserialize (this.deserialize) to convert a string value to its original value type. It worked fine until I tried to convert "false" to false. It returns true all the time. I checked the method and I found this:

case Boolean:
  value = value !== null;

I understand that value could be anything but wouldn't be better to add something like this?

case Boolean:
  value = (value == 'false' || value == '0') ? false : value !== null;

Live Demo

https://jsbin.com/xerututizi/1/edit?html,output

Versions

  • Polymer: v1.2.4
  • webcomponents: v0.7.22

chimarcos avatar Jun 16 '16 19:06 chimarcos

Closing this issue as deserialize has been deprecated and is now on the legacy element mixin.

TimvdLippe avatar Aug 16 '17 02:08 TimvdLippe