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

selection.size() throws error when called on enter selection #2043

Closed
jshanley opened this issue Oct 3, 2014 · 2 comments
Closed

selection.size() throws error when called on enter selection #2043

jshanley opened this issue Oct 3, 2014 · 2 comments
Labels
bug Something isn’t working documentation Improvements or additions to docs
Milestone

Comments

@jshanley
Copy link

jshanley commented Oct 3, 2014

Calling the .size() method on an enter selection throws:

Uncaught TypeError: undefined is not a function

This appears to be due to the fact that the selection.each() method is undefined for enter selections, and is used internally by the selection.size() method.

The problem can be resolved by having d3_selection_enterPrototype inherit the .each method from d3_selectionPrototype in src/selection/enter.js as is being done with the other methods available to enter selections, including the .size method.

However, I'm not sure if doing this will introduce other issues. The tests pass. Is there a specific reason that the each method should not be inherited by the enter selection prototype?

@jasondavies
Copy link
Contributor

Thanks for the report! Strange that selection.enter.size is not documented at the moment, but it should indeed be supported it seems from looking at the code. The code does rely erroneously on .each being present, but this has been discussed previously in #824, and I think it was decided it shouldn’t be added.

I have proposed an alternative fix using the private d3_selection_each method in #2046.

@jasondavies jasondavies added bug Something isn’t working documentation Improvements or additions to docs labels Oct 3, 2014
@jasondavies jasondavies added this to the 3.4.x milestone Oct 3, 2014
@mbostock
Copy link
Member

mbostock commented Oct 8, 2014

Fix merged into #2053.

@mbostock mbostock closed this as completed Oct 8, 2014
dribnet added a commit to dribnet/d3 that referenced this issue Oct 10, 2014
Patched a minor merge conflict in fix-format
caused by jasondavies commit 519f258.

Confirmed to pass tests including new tests in
test/format/format-test.js

Merge branch 'master' into fix-format

* master:
  Fix for JSDOM update.
  Add d3.zip target.
  Bump version.
  Save two minified bytes.
  Fix d3#2043: selection.enter.size.
  Update to JSDom 1.0.0
  Fix d3#2040: parsing time zone offsets.
  Workaround for Chrome touchmove issue 412723.
  Replace substring with slice.
  Fix a few imports.
  Fix InvalidStateError for non-text local files.

Conflicts:
	d3.js
	d3.min.js
	src/locale/number-format.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn’t working documentation Improvements or additions to docs
Development

No branches or pull requests

3 participants