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

Browser says "SyntaxError: '' is not a valid selector" #79

Open
honix opened this issue Mar 29, 2017 · 4 comments
Open

Browser says "SyntaxError: '' is not a valid selector" #79

honix opened this issue Mar 29, 2017 · 4 comments

Comments

@honix
Copy link

honix commented Mar 29, 2017

Firefox 51.0.1 (64-bit) at Arch Linux

Browser console:
SyntaxError: '' is not a valid selector skewer:210
query http://127.0.0.1:8080/skewer:210:16
skewer.fn.html http://127.0.0.1:8080/skewer:218:18
callback http://127.0.0.1:8080/skewer:14:22
skewer.getJSON/xhr.onreadystatechange http://127.0.0.1:8080/skewer:39:13

@skeeto
Copy link
Owner

skeeto commented Mar 29, 2017 via email

@terminalcommand
Copy link

terminalcommand commented Nov 15, 2017

Hello, same error happens to me on Firefox 56 on Lubuntu 17.10.

After I run M-x run-skewer and switch to skewer-repl, any command I type and send causes this error.

I've set up chromium as my browser and tried it again, it gives an error on the same line, but the error message is more explanatory.

Failed to load resource: the server responded with a status of 404 (Not Found)
skewer:212 Uncaught DOMException: Failed to execute 'querySelector' on 'Document': The provided selector is empty.
at query (http://127.0.0.1:8080/skewer:212:25)
at Object.skewer.fn.html (http://127.0.0.1:8080/skewer:220:18)
at callback (http://127.0.0.1:8080/skewer:14:45)
at XMLHttpRequest.xhr.onreadystatechange (http://127.0.0.1:8080/skewer:40:13)

The function that gives the error is:
function query(ancestry) { return document.querySelector(buildSelector(ancestry)); // this line is problematic }

buildSelector(ancestry) returns empty, and therefore document.querySelector(nil) fails.

I installed skewer directly from melpa.

I'd be happy to provide more information.

@Ruin0x11
Copy link

Ruin0x11 commented Apr 7, 2018

Happens to me also. Running the demo included with skewer fails with the same message. I used Chrome 65 on Windows 7.

Uncaught DOMException: Failed to execute 'querySelector' on 'Document': The provided selector is empty.
    at query (http://127.0.0.1:8080/skewer:212:25)
    at Object.skewer.fn.html (http://127.0.0.1:8080/skewer:220:18)
    at callback (http://127.0.0.1:8080/skewer:14:45)
    at XMLHttpRequest.xhr.onreadystatechange (http://127.0.0.1:8080/skewer:40:13)

It seems to try evaluating the top-level HTML tag on startup but fails because the ancestry list is null, which ends up creating a blank CSS selector. But the blank ancestry list is created in Emacs as well when I evaluate skewer-html-compute-tag-ancestry on the top level tag.

As a workaround I modified skewer-html-compute-tag-ancestry as follows:

(defun skewer-html-compute-tag-ancestry ()
  "Compute the ancestry chain at point."
  (skewer-html--with-html-mode
    (nreverse
     (cl-loop for tag in (skewer-html--get-context)
              for nth = (skewer-html-compute-tag-nth (1+ (sgml-tag-start tag)))
              for name = (skewer-html--cleanup tag)
              ;;unless (equal name "html")
              collect (list name nth)))))

This way an html tag will always be included in the ancestry. Then everything works swimmingly.

@vlnn
Copy link

vlnn commented Sep 26, 2021

So.. any progress on this? The problem is still there as far as I see. @skeeto do you think the solution provided by @Ruin0x11 is good enough to be merged?

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

5 participants