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

Unexpected token: ';' #657

Closed
emilos opened this issue Nov 1, 2020 · 8 comments
Closed

Unexpected token: ';' #657

emilos opened this issue Nov 1, 2020 · 8 comments
Labels
bug Something isn't working

Comments

@emilos
Copy link
Contributor

emilos commented Nov 1, 2020

Seems to work correctly, but shows an error in the console:

<style>
  div[class*="status-"]::after {
    content: "";
    display: block;
    position: absolute;
    width: 100%;
    height: 100%;
    background-repeat:  no-repeat;
    background-position: bottom center;
    background-size: contain;
    opacity: 0.1;
  }
  .status-400::after {
    background-image: url('/assets/images/400.svg');
  }
  .status-401::after {
    background-image: url('/assets/images/401.svg');
  }
  .status-403::after {
    background-image: url('/assets/images/403.svg');
  }
  .status-404::after {
    background-image: url('/assets/images/404.svg');
  }
  .status-500::after {
    background-image: url('/assets/images/500.svg');
  }
</style>
@emilos emilos added the bug Something isn't working label Nov 1, 2020
@inikonorov
Copy link
Contributor

can you share what version of node do you test? I use 14.11.0 - everything is ok (screen below).
image

@inikonorov
Copy link
Contributor

inikonorov commented Nov 18, 2020

@emilos hey, can you comment this?)

@emilos
Copy link
Contributor Author

emilos commented Nov 18, 2020

@inikonorov I'm trying to reproduce this again, but without much luck :) going to try again now.

@emilos
Copy link
Contributor Author

emilos commented Nov 18, 2020

@inikonorov ok, I've found it. I've added a skipped spec here c1e570d if you want to have a look :) thanks!

@inikonorov
Copy link
Contributor

inikonorov commented Nov 24, 2020

I play with code and found something
I think, that problem is if-condition (35-37 rows) in prerun function in plugins/DataPlugin.js
I made some tests:

  • 1 test (current if-condition and template from c1e570d commit
    image

  • 2 test (current if-condition and my template based on template from 1st test
    image

  • 3 test (changed if-condition and template from 1st test)
    image

I think, that when optimizeNode function finds curly brackets in style tag, she thinks that in curly brackets there is some JS code. So 2nd test works correctly, because in curly brackets there is a real JS code.
I don't know is 3rd test's if-condition right and I can do pull request with this solution, so I wait your opinion about this :)

@emilos
Copy link
Contributor Author

emilos commented Nov 24, 2020

@inikonorov this makes a lot of sense, good find! This seems to be a wider problem, I think same issue would happen if we would have a script tag defined with something inside of it (or any other tag that can take in code).

I think the right solution for this, is to do something like this inside of the DataPlugin

const CODE_TAGS = ['style', 'script']

// ...

if (CODE_TAGS.includes(tag)) {
   fragment.children.forEach(node => {
     node.skipDataOptimization = true
   })
}

// ...

if (this.variables.length > 0 && !fragment.skipDataOptimization) {
  // ...
}

@inikonorov
Copy link
Contributor

okay, 'll do this today :)

@inikonorov
Copy link
Contributor

#667

@emilos emilos closed this as completed Nov 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants