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

Fix <range-input disabled> #195

Merged
merged 4 commits into from
Oct 20, 2018
Merged

Fix <range-input disabled> #195

merged 4 commits into from
Oct 20, 2018

Conversation

developit
Copy link
Collaborator

This fixes the .disabled property reflection for range-input. Previously, only the disabled attribute worked.

Fixes #142.

@jakearchibald
Copy link
Collaborator

It looks like disabled never reaches the underlying input. Also, I can't figure out why it didn't work before. The property getter/setter reflected the value from the input.

@developit
Copy link
Collaborator Author

The styling relies on range-input[disabled].

@jakearchibald
Copy link
Collaborator

This PR may fix the styling but it breaks the behaviour 😄 .

Feels like the original problem is with if (attributeValue === null) continue; in _reflectAttributes(), and it should remove the attribute instead? However, from memory, I think that broke something, so if you do that be sure to test.

@developit
Copy link
Collaborator Author

Yeah I'm kinda stumped here - it seems like the (prior to this PR) reflection should have worked since it does:

this._input.disabled = true
this.setAttribute('disabled', this._input.getAttribute('disabled'))

...which should be equivalent to setAttribute('disabled', '')...

@surma
Copy link
Collaborator

surma commented Oct 19, 2018

this.setAttribute('disabled', this._input.getAttribute('disabled')
...which should be equivalent to setAttribute('disabled', '')...

For the disabled=true case that is correct, but not for disabled=false.

+1 to Jake. I think the error is in line 97:

if (attributeValue === null) continue;

should do an removeAttribute().

// edit: I just realized that y’all are talking about the set case, not the unset case.

@surma
Copy link
Collaborator

surma commented Oct 19, 2018

Side note: The REFLECTED_X array and the method _reflectAttributes() should really be called _passthroughAttributes() or something. This isn’t really the normal reflection, isn’t it?

@googlebot
Copy link

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of all the commit author(s), set the cla label to yes (if enabled on your project), and then merge this pull request when appropriate.

@surma
Copy link
Collaborator

surma commented Oct 19, 2018

We had a rogue for-in loop instead of a for-of loop. And the line Jake and I pointed out.

screen shot 2018-10-19 at 1 34 28 pm

@developit
Copy link
Collaborator Author

Ahh wow yeah that'd be from the back and forth we did on the reflection approach. The hasAttribute thing is fine, though it doesn't seem like that was the cause of the .disabled bug.

@surma
Copy link
Collaborator

surma commented Oct 19, 2018

The difference is the explicit "removeAttribute" call. See previous commit.

@jakearchibald jakearchibald merged commit a79f95b into master Oct 20, 2018
@jakearchibald jakearchibald deleted the fix-range-input-disabled branch October 20, 2018 11:51
alisaitbilgi pushed a commit to alisaitbilgi/squoosh that referenced this pull request Feb 19, 2019
* Fix .disabled property reflection for range-input (only attribute worked previously)

* Revert "Fix .disabled property reflection for range-input (only attribute worked previously)"

This reverts commit f596463.

* Fix reflection

* Use hasAttribute()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Range input: implement 'disabled'.
4 participants