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

Fix example of output element to use ids instead of names #3313

Merged
merged 1 commit into from
Jan 2, 2018

Conversation

frigus02
Copy link
Contributor

@frigus02 frigus02 commented Dec 28, 2017

Fixes #3312

The first example of the output element incorrectly referenced input elements in the for attribute by their names:

<form onsubmit="return false" oninput="o.value = a.valueAsNumber + b.valueAsNumber">
 <input name=a type=number step=any> +
 <input name=b type=number step=any> =
 <output name=o for="a b"></output>
</form>

I added IDs to the input elements and used them in the for attribute. The example looks like this now:

<form onsubmit="return false" oninput="o.value = a.valueAsNumber + b.valueAsNumber">
 <input id="number-a" name=a type=number step=any> +
 <input id="number-b" name=b type=number step=any> =
 <output name=o for="number-a number-b"></output>
</form>

Another option would be to only use IDs:

<form onsubmit="return false" oninput="o.value = a.valueAsNumber + b.valueAsNumber">
 <input id=a type=number step=any> +
 <input id=b type=number step=any> =
 <output id=o for="a b"></output>
</form>

Personally I prefer the first example with separate names and IDs, though.

Please let me know if anything is missing or if this fix is wrong entirely.


/acknowledgements.html ( diff )
/form-elements.html ( diff )

@@ -121036,6 +121036,7 @@ INSERT INTERFACES HERE
James Perrett,
James Robinson,
Jamie Lokier,
Jan K&uuml;hle, <!-- frigus02 on GitHub -->

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excuse me, maybe its rude to ask, but is Kühle is really your last name or there are two mistakes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's ok to ask. Kühle is my last name. You can also see it on my GitHub profile.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh Im noob. Never thought that this &uuml; would be transpiled to ü. Thanks for your contribution though

@TimothyGu
Copy link
Member

I think having just the ID is fine. If not for the current confusion in the example one probably wouldn’t have mistaken one for the other.

@frigus02
Copy link
Contributor Author

frigus02 commented Dec 29, 2017

I was mainly thinking about the oninput event handler. Currently it uses names, which are only available in the scope of the form. When using IDs it resolves these from the global scope. All other examples with IDs use document.getElementById to find the element.

I don't mind changing the example to only IDs, though. Should I convert the oninput handler to use document.getElementById, too? Or just use example as I wrote it above?

The first example of the output element incorrectly referenced input
elements in the "for" attribute by their names. This changes the
example to reference input elements by their ids instead (whatwg#3312).
@domenic
Copy link
Member

domenic commented Jan 2, 2018

Sorry for the delay on getting back to you here. I think it's totally fine to use any style here: ids + names, ids only with global variable access, ids only with getElementById... The style of examples in the spec is varied, on purpose, to illustrate all the different ways you can write code.

So, I think in the end, the question is what you'd prefer, @frigus02 :). And in your OP you said you preferred separate, so let's do that.

@domenic
Copy link
Member

domenic commented Jan 2, 2018

Well, OK, I see after writing that that you switched to only ids. So, uh, just let me know if you want to merge it as-is, or if you want to revert to separate and I'll merge that. Either way!

@domenic domenic self-assigned this Jan 2, 2018
@frigus02
Copy link
Contributor Author

frigus02 commented Jan 2, 2018

Hey @domenic. Don't worry about the delay. I didn't expect prompt feedback during the holidays. :-)

You can merge it as as, using only ids. That's fine for me.

@domenic domenic merged commit 58a8817 into whatwg:master Jan 2, 2018
@frigus02 frigus02 deleted the issue-3312 branch January 2, 2018 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

Example for <output> uses name instead of id when referring to for elements
4 participants