Skip to content

Null error in js console if nav.docx is empty #170

@alexkli

Description

@alexkli

Expected Behaviour

No errors if my navigation document is empty (yet).

I like my browser js console clean from framework errors :) But it's a minor issue.

Actual Behaviour

With an empty nav.docx (see below), I see this error in the js console (using localhost:3000 dev server):

failed to load module for header TypeError: Cannot read properties of null (reading 'querySelectorAll')
    at toggleAllNavSections (header.js:44:12)
    at toggleMenu (header.js:60:3)
    at Module.decorate (header.js:138:5)
    at async lib-franklin.js:360:15

This is because this line here does not check if sections is null nor not.

Empty nav.docx: The nav.plain.html seen in the browser looks like this:

<div></div>

Reproduce Scenario (including but not limited to)

Steps to Reproduce

  1. have an empty navigation doc (e.g. nav.docx)
  2. use default boilerplate code
  3. run hlx up
  4. open any page in localhost:3000

Platform and Version

boilerplate: https://github.com/adobe/helix-project-boilerplate/tree/a906cfc82b7a6f807e6a1899fa69a062ade2a0bc

franklin-simulator v14.20.0

Sample Code that illustrates the problem

Standard boilerplate code.

Logs taken while reproducing problem

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions