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

no-js logic (set classes) got a conflict with head options #54

Open
valeriosillari opened this issue Sep 24, 2021 · 0 comments
Open

no-js logic (set classes) got a conflict with head options #54

valeriosillari opened this issue Sep 24, 2021 · 0 comments

Comments

@valeriosillari
Copy link

Hi, just started to use this package and it seems quite nice.
But I noticed a isse on my code and not sure if depending on my code, this package or nuxt logic itself and I would liek to ask some help.

Here a description of my issue (steps):

  1. I've installed the package following the documentation. All is fine.

  2. Because I want to use the "no-js / js class" logic for setting a class on html element (the "setClasses" option from Modernizr itself), I did the following: set the option as shown on package documentation, then added 'no-js' class to the html tag from nuxt config file, as following:

``
head: {
...

htmlAttrs: {

  class: 'no-js',

},

...

}
``

Also here all was fine.
Page is loaded, and class "no-js" added on DOM (by Nuxt htmlAttrs). Then JS on client is loaded, also Modernizr, and class "no-js" is changed to class "js" by Modernizr.

  1. Then here the issue: on a page (call this page "subpage") I've decided to overwrite, in the page itself by the method "head", the title of the page.
    This is working, but as side effects I've noticed that when I navigate from the homepage to the "subpage", the no-js/js class set by modernizr is kind of "reset".

My possible explanation
After several tests, it seems that the setClasses logic is kind of 'reset' any time in a Vue page or Vue component I set the "head" property and try to overwrite ANY options in it (at page change).

In this way the Modernizr "setClasses" logic (what I use to call "no-js / js class trick") seems crashing or at least reset to the value set in nuxt config file (".no-js").

My question
Anyone experienced this issue? is this an issue related to this package, or to Nuxt logic in general?
Could anyone support me on this issue?

I've also set a test repo where I've set some basic code as documentation here:
https://github.com/valeriosillari/nuxt-modernizr-test

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

1 participant