Skip to content
This repository has been archived by the owner on Dec 19, 2024. It is now read-only.

Use of a nested attributes results in string values when using paper-slider #175

Open
2 tasks done
pik opened this issue Mar 7, 2017 · 2 comments
Open
2 tasks done

Comments

@pik
Copy link

pik commented Mar 7, 2017

Description

Use of a nested attribute passed to a paper-slider will cause it to always set a string value.

Expected outcome

paper-slider should set a number.

Actual outcome

      _changeValue: function(event) {
       # Break Here
        this.value = event.target.value;
        this.fire('change');
      }
> event.target
<input is="iron-input" id="input" class="style-scope paper-input" autocomplete="off" placeholder autocapitalize="none" autocorrect="off" aria-describedby aria-labelledby="paper-input-label-8" type="number" tabindex="0" max="100" min="0" step="1">> event.target.value
"1"

Note that the event.target.value is a String not numeric and the assignment below will cause the passed in property to receive a string.

I guess parsing the string to a number might be the easiest solution, or is there something else going on here?

Steps to reproduce

       <div>Slider on a nested attribute: </div>

      <paper-slider id="slider1" min="0" max="100" value={{settings.sliderValue}} editable></paper-slider>
      <div>Slider on a primary attribute: </div>
      <paper-slider id="slider2" min="0" max="100" value={{sliderValue}} editable </paper-slider>

Browsers Affected

  • Chrome
  • Firefox
@keanulee
Copy link
Contributor

<input>s and <paper-input>s, even type=number, always return a string value, so that's why event.target.value is a string. It seems to make sense to do this.value = parseFloat(event.target.value) in _changeValue - WDYT @notwaldorf (who's more familiar with <paper-input>)?

@pik
Copy link
Author

pik commented Mar 10, 2017

Yeah that's what I ended up doing (pik@834b477) not sure if it's the technically correct fix though..

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants