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

HTML element boolean attribute handling spec conformance #394

Closed
kellytk opened this issue Sep 7, 2018 · 2 comments
Closed

HTML element boolean attribute handling spec conformance #394

kellytk opened this issue Sep 7, 2018 · 2 comments

Comments

@kellytk
Copy link
Contributor

kellytk commented Sep 7, 2018

Description

I'm submitting a ...

  • bug report

The handling of the following true condition appears to be out of spec:

let is_disabled = true;

<input disabled=is_disabled,/>

Expected Results

<input disabled>
//or
<input disabled="">
//or
<input disabled=disabled>

Actual Results

<input disabled="true">

Please note the following quotes from the spec:

If the attribute is present, its value must either be the empty string or a value that is an ASCII case-insensitive match for the attribute’s canonical name, with no leading or trailing white space.

A boolean attribute without a value assigned to it (e.g. checked) is implicitly equivalent to one that has the empty string assigned to it (i.e. checked=""). As a consequence, it represents the true value.

The values "true" and "false" are not allowed on boolean attributes. To represent a false value, the attribute has to be omitted altogether.

I expect that the flawed behavior affects all boolean attributes however I've not confirmed that.

For completeness, the following false condition behaves as expected, omitting the disabled attribute entirely:

let is_disabled = false;

<input disabled=is_disabled,/>
<input>
@untitaker
Copy link

This is annoying with <textarea> and readonly: Any value of readonly will make the textarea readonly, also this one is permanently readonly:

<textarea readonly=false />

@estk
Copy link

estk commented Oct 19, 2018

Thanks for pointing this out @kellytk . @deniskolodin this is also a problem with elements and the selected attr, the attr's value is always to_string'd, so as you can imagine, the <option> is always selected.

mrh0057 added a commit to mrh0057/yew that referenced this issue Jan 3, 2020
mrh0057 added a commit to mrh0057/yew that referenced this issue Jan 3, 2020
jstarry pushed a commit that referenced this issue Jan 6, 2020
* Updated so boolean attributes are either there or not.

Issue #394

* Ran cargo fmt.

* Updated to remove checked and selected special handling.

* Update the attribute list to match what mdn says.

Removed deceprated attributes.

* Added back the checked special handling.
@kellytk kellytk closed this as completed Jan 6, 2020
llebout pushed a commit to llebout/yew that referenced this issue Jan 20, 2020
* Updated so boolean attributes are either there or not.

Issue yewstack#394

* Ran cargo fmt.

* Updated to remove checked and selected special handling.

* Update the attribute list to match what mdn says.

Removed deceprated attributes.

* Added back the checked special handling.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants