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

Issue when HTML element's id string is passed to Builder constructor #342

Open
pitkunait opened this issue Feb 3, 2021 · 0 comments
Open

Comments

@pitkunait
Copy link

pitkunait commented Feb 3, 2021

Builder constructor throws an error if element id is passed to it as string.

class Builder {
  constructor (mapData, modelData, embeddedCss, selection, options) {
    // Defaults
    if (!selection) {
      selection = d3Select('body').append('div')
    } else if (selection instanceof d3Selection) {
      // D3 V4 selection
    } else if ('node' in selection) {
      // If user passes in a selection from an different d3 version/instance,
      // then reselect.
      selection = d3Select(selection.node())
    } else {
      // HTML Element
      selection = d3Select(selection)
    }

Would add additional check here:

class Builder {
  constructor (mapData, modelData, embeddedCss, selection, options) {
    // Defaults
    if (!selection) {
      selection = d3Select('body').append('div')
    } else if (selection instanceof d3Selection) {
      // D3 V4 selection
    } else if (typeof selection === 'object' && 'node' in selection) {
      // If user passes in a selection from an different d3 version/instance,
      // then reselect.
      selection = d3Select(selection.node())
    } else {
      // HTML Element
      selection = d3Select(selection)
    }
@pitkunait pitkunait changed the title issue with passing selection HTML element id to Builder constructor issue when HTML element's id string is passed to Builder constructor Feb 3, 2021
@pitkunait pitkunait changed the title issue when HTML element's id string is passed to Builder constructor Issue when HTML element's id string is passed to Builder constructor Feb 3, 2021
@pitkunait pitkunait changed the title Issue when HTML element's id string is passed to Builder constructor Issue when HTML element's id string is passed to Builder constructor😡 Feb 3, 2021
@pitkunait pitkunait changed the title Issue when HTML element's id string is passed to Builder constructor😡 Issue when HTML element's id string is passed to Builder constructor Feb 3, 2021
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

No branches or pull requests

1 participant