support boolean values for boolean attributes

Open
#20 7 comments 1 reaction 0 assignees View on GitHub

@schneiderfelipe is already working on this.

Since May 21, 2021.

  • #35 by @schneiderfelipe — open

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
42/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
julia
Domain
frontend

Research direction

The issue names no source file or test; start by locating how Hyperscript.jl serializes HTML attributes and reviewing existing attribute-related tests. Define done as supporting boolean values so false omits the attribute and true emits an HTML5-conforming boolean attribute, with tests covering both cases.

Written by the indexing model from the issue text.

Description

Even though the correct HTML5 thing to do is to use valueless boolean attributes or to not add them at all (i.e. <input type=checkbox checked /> versus <input type=checkbox />), this becomes a bit awkward when generating them programmatically. In particular, if one wants to add observables to Hyperscript to add interactivity (see https://github.com/SimonDanisch/JSServe.jl/pull/35 for instance), things become a bit awkward.

From what I understand, HTML5 actually disallows using "true" or "false" as values for boolean attributes (see here). Could it be possible to support passing checked = false to mean that the attribute is actually not set, and checked = true to set it?

I confess I'm not sure what the attribute should be set to with checked = true, but I imagine anything that conforms to HTML5 would be fine (empty string, or name of the attribute, or maybe even valueless).

Dominant language
Julia
Stars
105
Forks
12
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from JuliaWeb/Hyperscript.jl

All issues in JuliaWeb/Hyperscript.jl

Similar issues

More Julia issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.