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

Return value for DOMTokenList's replace() #577

Closed
Zirro opened this issue Feb 23, 2018 · 2 comments
Closed

Return value for DOMTokenList's replace() #577

Zirro opened this issue Feb 23, 2018 · 2 comments

Comments

@Zirro
Copy link
Contributor

Zirro commented Feb 23, 2018

DOMTokenList's replace() method does not currently have a specified return value. While using it I've had code which takes different paths depending on whether a replacement occurred or not. To find out if this was the case I must currently use separate conditions with contains().

Could replace(oldToken, newToken) return a boolean indicating true if oldToken was indeed present and got replaced by newToken? This would help with writing cleaner code, and there's some precedent in the toggle(token)-method which returns true or false depending on whether the call resulted in the addition or removal of the token.

Given the relatively recent introduction of replace(), there's probably a good chance that this change is web compatible.

@annevk
Copy link
Member

annevk commented Feb 24, 2018

I like that. Copying @wycats who advocated for this feature to see if he agrees.

Zirro added a commit to Zirro/dom that referenced this issue Mar 4, 2018
The replace() method returns true if token was
replaced with newToken, and false otherwise.

Fixes whatwg#577.
@Zirro
Copy link
Contributor Author

Zirro commented Mar 4, 2018

I've opened #582 with an initial take of the spec changes, while awaiting more feedback here.

Zirro added a commit to Zirro/dom that referenced this issue Mar 7, 2018
The replace() method returns true if token was
replaced with newToken, and false otherwise.

Fixes whatwg#577.
Zirro added a commit to Zirro/web-platform-tests that referenced this issue Mar 8, 2018
annevk pushed a commit that referenced this issue Mar 12, 2018
The replace() method returns true if token was replaced with newToken, and false otherwise.

Tests: web-platform-tests/wpt#9920.

Fixes #577.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants