Skip to content

Bugfix: "Cannot read property 'firstElementChild' of null" (WFS) #3118

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

Merged

Conversation

brianreavis
Copy link
Contributor

Occurs when the WFS FeatureCollection is empty.

@bartvde
Copy link
Member

bartvde commented Jan 13, 2015

hey @brianreavis thanks for this, can you please add a testcase and format the code according to the guidelines, e.g. always { for if else. Also a code block is duplicated in your PR:

node = node.firstElementChild;
+  if (!goog.isDefAndNotNull(node)) return null;

@elemoine
Copy link
Member

Too bad this is not enforced by the linter. Maybe there is an option we can pass to jshint.

@brianreavis
Copy link
Contributor Author

@bartvde Yeah, I can add in the brackets. The code block is intentionally duplicated:

// original line:
node = node.firstElementChild.firstElementChild;

// expanded form:
node = node.firstElementChild;
node = node.firstElementChild;

@bartvde
Copy link
Member

bartvde commented Jan 13, 2015

ah okay I'd use || in that case (and a single if statement) for more code clarity

@bartvde
Copy link
Member

bartvde commented Jan 13, 2015

or protect the for loop with:

if (goog.isDefAndNotNull(node.firstElementChild) && goog.isDefAndNotNull(node.firstElementChild.firstElementChild)) {

brianreavis added a commit to naturalatlas/ol3-fork that referenced this pull request Jan 13, 2015
@brianreavis
Copy link
Contributor Author

@bartvde @elemoine Okay, this should be good to go now

@bartvde
Copy link
Member

bartvde commented Jan 13, 2015

thanks @brianreavis last step would be to clean up the git history with a git rebase, are you familiar with that?

@brianreavis brianreavis force-pushed the wfs-firstelementchild-bugfix branch from e9da208 to 37dac8e Compare January 13, 2015 08:41
…rojectionFromNode.

Occurs when a FeatureCollection is empty.

Code style changes @bartvde

Added test case for openlayers#3118.

Attempt to make jshint happy.

Fixed tab character.

Another code style change (jshint)....
@brianreavis
Copy link
Contributor Author

Done. Does OL have any plans on relaxing the style? The strictness (line length in particular) is making code readability and contribution a mess.

@bartvde
Copy link
Member

bartvde commented Jan 13, 2015

@brianreavis
Copy link
Contributor Author

Done...

@bartvde
Copy link
Member

bartvde commented Jan 13, 2015

thanks for your contribution and patience @brianreavis

bartvde added a commit that referenced this pull request Jan 13, 2015
Bugfix: "Cannot read property 'firstElementChild' of null" (WFS)
@bartvde bartvde merged commit 35468e2 into openlayers:master Jan 13, 2015
@elemoine
Copy link
Member

Done. Does OL have any plans on relaxing the style?

I'd say that we're pretty happy with what we use :-)

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.

3 participants