This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 22321 - Spec for DOMTokenList.toggle is very confusing
Summary: Spec for DOMTokenList.toggle is very confusing
Status: RESOLVED FIXED
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: DOM (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Anne
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-06-10 19:31 UTC by Boris Zbarsky
Modified: 2013-06-19 08:31 UTC (History)
2 users (show)

See Also:


Attachments

Description Boris Zbarsky 2013-06-10 19:31:48 UTC
The four consecutive if statements might be more clear as 3 nested ones... (so a toplevel if, and then one if in each branch).
Comment 1 Anne 2013-06-12 09:11:22 UTC
So like this?

3. If token is in the list of tokens, run these substeps:

  3.1 If force is not true (force is either false or omitted), then remove token from the list of tokens, run the update steps, and return false.

  3.2 Otherwise, return true.

4. Otherwise, run these substeps:

  4.1 If force is false (false is neither true nor omitted), return false.

  4.2 Otherwise, append token to the list of tokens, run the update steps, and return true.
Comment 2 Boris Zbarsky 2013-06-12 17:07:48 UTC
Yes, though I'd probably invert the test in 3.1 to look more like 4.1 (so "if force is false").

A terminology question: are we using "omitted" or "not passed" for optional arguments?  As in, could "force is false (false is neither true nor omitted)" be more clearly written as "force was passed and is false"?  Or "force was not omitted and is false"?
Comment 3 Anne 2013-06-19 08:31:09 UTC
So that "is not true" means something different from "is false" given the ability to be omitted, making it a tri-state effectively.

Thanks for the suggestion though, the new text seems much clearer:

https://github.com/whatwg/dom/commit/acbce28fb425dddaa657f5c3ee304c4bd3d67ea5