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

section > h*:first selector used in some modules throwing exception on Chrome #311

Closed
halindrome opened this issue Apr 25, 2014 · 3 comments

Comments

@halindrome
Copy link
Contributor

In the core/fix-headers, core/structure, and w3c/informative a construct like this is used:

var $secs = $("section:not(.introductory)", doc)
.find("h1:first, h2:first, h3:first, h4:first, h5:first, h6:first");

Chrome is throwing an exception on this:

"Error: Failed to execute 'querySelectorAll' on 'Element': '[id='introduction'] h1:first,[id='introduction'] h2:first,[id='introduction'] h3:first,[id='introduction'] h4:first,[id='introduction'] h5:first,[id='introduction'] h6:first' is not a valid selector.
    at Error (native)
    at Function.ot (http://pandora.aptest.com/respec/js/jquery.js:4:9400)
    at x.fn.extend.find (http://pandora.aptest.com/respec/js/jquery.js:5:15275)
    at Object.run (http://pandora.aptest.com/respec/js/core/structure.js:87:34)
    at pipeline (http://pandora.aptest.com/respec/js/core/base-runner.js:113:40)
    at Object.run (http://pandora.aptest.com/respec/js/core/fix-headers.js:22:17)
    at pipeline (http://pandora.aptest.com/respec/js/core/base-runner.js:113:40)
    at Object.run (http://pandora.aptest.com/respec/js/core/dfn.js:33:17)
    at pipeline (http://pandora.aptest.com/respec/js/core/base-runner.js:113:40)
    at run.finish (http://pandora.aptest.com/respec/js/core/webidl-oldschool.js:1400:25)"

It is probably a bug in jQuery, really. But regardless, it is something we should fix. I believe that using :first-child will work instead of :first

@marcoscaceres
Copy link
Member

Strange, works fine in my document in Chrome? Could it be something wrong with the markup in your doc?

@halindrome
Copy link
Contributor Author

No.... I mean, you need to turn on the "pause on exceptions" in order for it to fail. My guess is that the exception gets thrown, and then jQuery handles it internally because it fails natively.

There's another exception that gets thrown if you happen to have a selector special character in the contents of a header that then gets turned into an ID.

@halindrome
Copy link
Contributor Author

Actually, while it does throw an exception, it obviously is working so it is probably a jQuery artifact where it is trying to use the native implementation first then failing over to the JS implementation of the selector logic. I will close this.

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