WebReflection / WebReflection/linkedom
In 'HTMLElement.classList.toggle' the 'force' attribute works uncorrectly.
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 2.1k
- Forks
- 104
- PR merge metrics
- No merged PRs in 30d
Description
export const toggle = <T extends HTMLElement> (className:string, force?:boolean) => (el:T) : boolean => el.classList.toggle(className, force)
toggle(className)(el)
In this example, if the 'force' attribute is not passed to the 'toggle' function, 'linkedom' will interpret it as being passed an attribute equal to 'undefined' and identify it as a 'false' value.
The correct way is for 'linkedom' to ignore the 'force' attribute if it is 'undefined'.
Everything works fine in the browser.
Аnd also in 'linkedom' everything works correctly if I do this check myself:
export const toggle = <T extends HTMLElement> (className:string, force?:boolean) => (el:T) : boolean => force === undefined ? el.classList.toggle(className) : el.classList.toggle(className, force)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate the implementation of HTMLElement.classList.toggle and compare its handling of an omitted force argument with the browser behavior described here. Verify that undefined is treated as an omitted argument while explicit boolean values still control the result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 50/100