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

Add optional initial_selection to DOM.select. #57

Closed
wants to merge 1 commit into from

Conversation

jaynel
Copy link

@jaynel jaynel commented Jun 9, 2018

No description provided.

@mbostock
Copy link
Member

Thanks for the PR! We’re probably going to deprecate DOM.select and related methods (see #31) in the near future in favor of HTML tagged template literals, so I don’t think it makes sense to add new functionality at this time.

For a static dropdown, I’d say:

html`<select>
  <option value="red">red</option>
  <option value="green" selected>green</option>
  <option value="blue">blue</option>
</select>`

For a data-driven one, something like:

colors = ["red", "green", "blue"]
html`<select>${colors.map(c => `
  <option value="${c}" ${c === "green" ? " selected" : ""}>${c}</option>`)}
</select>`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants