Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MDCSlider] MDCSliderFoundation: 'value' must be non-null #7603

Open
klyakh opened this issue Apr 27, 2022 · 0 comments
Open

[MDCSlider] MDCSliderFoundation: 'value' must be non-null #7603

klyakh opened this issue Apr 27, 2022 · 0 comments
Labels

Comments

@klyakh
Copy link

klyakh commented Apr 27, 2022

Bug report

*** Chrome ONLY ***

Initializing MDCSlider from dynamically created DOM tree (vie Vue runtime) leads to error in Chrome: MDCSliderFoundation: 'value' must be non-null

Steps to reproduce

  1. Example - https://codesandbox.io/s/mdc-slider-value-bug-sffqnz?file=/vue.html:1508-1641
  2. Slider's HTML is wrapped by div, which is root for Vue app. Therefore this HTML will be treated as template and respective DOM tree will be created by Vue runtime.
  3. The app just initializes MDCSlide component.
  4. See error

Your Environment:

Software Version(s)
MDC Web 13.0.0
Browser Chrome 101
Operating System Win

Additional context

The error happens during processing "value" attribute. I guess it happens because slider's HTML is treated as template by Vue. Vue creates respective input element and adds it to DOM tree. I don't know details, but I guess they set value not via setAttribute but via .value property. So the attribute remains unset.
Also I believe Chrome recently changed getAttribute implementation to comply with W3C. Before if attribute is null, respective property would be returned. Now it only returns attribute value as is. Here are some related links:

I think this error is not specific to Vue. It will happen to all dynamically created sliders, which value is set via .value property, not via setAttribute().

Possible solution

Most likely need to use .value property instead of getAttribute to get slider's initial value.

Temporary workaround

The example contains fix (commented lines) for the issue. Just call setAttribute before creating MDCSlider component.

@klyakh klyakh added the bug label Apr 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant