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

[SyntaxError: Unmatched selector: (http] #30

Closed
shmulim opened this issue Dec 30, 2013 · 9 comments
Closed

[SyntaxError: Unmatched selector: (http] #30

shmulim opened this issue Dec 30, 2013 · 9 comments

Comments

@shmulim
Copy link

shmulim commented Dec 30, 2013

I got the following error when using uncss:

Running "uncss:dist" (uncss) task
[SyntaxError: Unmatched selector: (http]
>> Uncssing source "docs/index.html" failed.
Warning: Uncss failed.� Use --force to continue.

Aborted due to warnings.

This is my package.json:

{
  "name": "ExampleApp",
  "version": "0.0.1",
  "private": true,
  "devDependencies": {
    "grunt": "~0.4.2",
    "grunt-cli": "~0.1.11",
    "grunt-uncss": "~0.1.5",
    "grunt-processhtml": "~0.2.7"
  }
}

And this is my Gruntfile.js:

module.exports = function(grunt) {
    grunt.initConfig({

        uncss: {
            dist: {
                files: {
                    'docs/tidy.css': ['docs/index.html']
                }
            },
            options: {
                compress:true,
            }
        },

        processhtml: {
            dist: {
                files: {
                    'docs/new/index.html': ['docs/index.html']
                }
            }
        }
    });

    grunt.loadNpmTasks('grunt-uncss');
    grunt.loadNpmTasks('grunt-processhtml');

    grunt.registerTask('default', ['uncss','processhtml']);

};

Can you please elaborate on why I'm getting this error?

@sedovsek
Copy link
Contributor

Dear @shmulim,

Would you mind sharing your index.html as well?

Best,
Robert.

@shmulim
Copy link
Author

shmulim commented Dec 30, 2013

Hi @sedovsek,

Unfortunately I can't share that without modification because I'm contract bound. Is there one particular part you'd like to share?

Thanks!

@sedovsek
Copy link
Contributor

@shmulim, well as far as I can tell, the source of the issue is somewhere in your index.html file, not in your setup.
But I might be wrong.

@shmulim
Copy link
Author

shmulim commented Dec 30, 2013

@sedovsek,

I get the same error even from the most minimalistic index.html, such as this:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">

  <!-- build:css docs/tidy.css -->
  <link rel="stylesheet" href="css/stylesheet_example1.css">
  <link rel="stylesheet" href="css/stylesheet_example2.css">
  <link rel="stylesheet" href="css/stylesheet_example3.css">
  <link rel="stylesheet" href="css/stylesheet_example4.css">
  <link rel="stylesheet" href="css/stylesheet_example5.css">
  <link rel="stylesheet" href="css/stylesheet_example6.css">
  <!-- /build -->

  <script src="js/script_example1.js"></script>
  <script src="js/script_example2.js"></script>
  <script src="js/script_example3.js"></script>
  <script src="js/script_example4.js"></script>
  <script src="js/script_example5.js"></script>
  <script src="js/script_example6.js"></script>

</head>

<body>

</body>

</html> 

@sedovsek
Copy link
Contributor

Have you looked at your CSS?
Looks like one of your selectors is "(http", which isn't valid CSS selector.

@shmulim
Copy link
Author

shmulim commented Dec 31, 2013

The only thing that I can think of is that in one of my stylesheets I'm pulling in a background from cloudinary using a url, but I don't have any http selectors "proper". I also have base64 in my CSS. That could be throwing off the parser. I don't know...

@sedovsek
Copy link
Contributor

I've tried both (remote background images and base64 encoded files) and it works.
Please try to replicate the minimum code that causes problem.

@giakki
Copy link
Member

giakki commented Dec 31, 2013

We actually had a similar problem before (see uncss/uncss#3). The "SyntaxError: Unmatched selector" pops up when cheerio-select can't parse a CSS selector.
If you could find the line that contains "(http", and try to replicate it, I can look into it!

@addyosmani
Copy link
Member

@shmulim could you re-post this issue upstream to https://github.com/giakki/uncss/issues? If we can debug it directly with uncss and solve the issue, grunt-uncss should be able to process it correctly.

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

4 participants