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

Infinite loop in explainer page #29

Open
erights opened this issue Jun 17, 2019 · 4 comments
Open

Infinite loop in explainer page #29

erights opened this issue Jun 17, 2019 · 4 comments

Comments

@erights
Copy link
Collaborator

erights commented Jun 17, 2019

var current = this.$toc;
says

  var current = this.$toc;
  var index = 0;
  while (index < path.length) {
    var children = current.children;
    for (var i = 0; i < children.length; i++) {
      if ('#' + path[index].id === children[i].children[1].getAttribute('href') ) {
         // ... update variable that might cause while loop to exit
      }      
    }
  }

In other words, if the if ('#'...) condition is false, none of current, index, or path are updated. The for loop always exits. The while loop never does.

This infinite loop causes the page to get stuck when viewed offline.
For reasons I did not diagnose, it does not cause the page to get stuck when viewed on the web.

I suspect this problem does not come from this repository. If so, please refile at the appropriate place.

@ljharb
Copy link
Member

ljharb commented Jun 18, 2019

This JS is generated by ecmarkup; but i can't fathom how viewing offline would affect anything - unless you're saying you were on the file:// protocol?

cc @bterlson

@erights
Copy link
Collaborator Author

erights commented Jun 18, 2019 via email

@erights
Copy link
Collaborator Author

erights commented Jun 18, 2019 via email

@ljharb
Copy link
Member

ljharb commented Jun 18, 2019

Many web features are broken on file://; the typical advice i give is to never use it, and instead go with a local http server. That said, ecmarkup's JS certainly shouldn't infinite loop there :-/

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

2 participants