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

With config enableClasses=true only css classes of async tests end up on html tag #2663

Open
jnehlmeier opened this issue Sep 7, 2021 · 1 comment

Comments

@jnehlmeier
Copy link

jnehlmeier commented Sep 7, 2021

Type of bug

Modernizr error

Describe the bug

I have selected a bunch of feature tests, some sync some async. However only the CSS classes of async tests end up on the html tag. Seems like the result of sync tests have been overridden.

How to Reproduce

Download Modernizr 3.11.8 from Github and install dependencies using npm install.

config:

{
  "classPrefix": "",
  "enableClasses": true,
  "enableJSClass": true,
  "scriptGlobalName": "window",
  "usePrefixes": true,
  "minify": false,
  "options": [
  ],
  "feature-detects": [
    "blob",
    "canvas",
    "cookies",
    "cors",
    "crypto",
    "crypto/getrandomvalues",
    "css/cssgrid",
    "css/customproperties",
    "css/displaytable",
    "css/flexbox",
    "css/flexwrap",
    "css/flexgap",
    "css/focuswithin",
    "css/fontdisplay",
    "css/fontface",
    "css/generatedcontent",
    "css/gradients",
    "css/lastchild",
    "css/mediaqueries",
    "css/nthchild",
    "css/objectfit",
    "css/pointerevents",
    "css/positionsticky",
    "css/pseudoanimations",
    "css/pseudotransitions",
    "css/transforms",
    "css/transforms3d",
    "css/transformslevel2",
    "css/transformstylepreserve3d",
    "css/transitions",
    "css/userselect",
    "css/valid",
    "css/vhunit",
    "css/vmaxunit",
    "css/vminunit",
    "css/vwunit",
    "css/will-change",
    "custom-elements",
    "customevent",
    "dataview-api",
    "dom/dataset",
    "dom/intersection-observer",
    "dom/mutationObserver",
    "dom/shadowroot",
    "elem/datalist",
    "elem/progress-meter",
    "es6/promises",
    "event/oninput",
    "eventlistener",
    "file/api",
    "forms/capture",
    "forms/fileinput",
    "forms/placeholder",
    "forms/validation",
    "hashchange",
    "hiddenscroll",
    "history",
    "htmlimports",
    "iframe/sandbox",
    "input",
    "inputtypes",
    "json",
    "mediaquery/hovermq",
    "messagechannel",
    "network/beacon",
    "network/connection",
    "network/connection-effectivetype",
    "network/eventsource",
    "network/fetch",
    "network/xhr2",
    "network/xhr-responsetype",
    "network/xhr-responsetype-arraybuffer",
    "network/xhr-responsetype-blob",
    "network/xhr-responsetype-document",
    "network/xhr-responsetype-json",
    "network/xhr-responsetype-text",
    "notification",
    "pagevisibility-api",
    "performance",
    "pointerevents",
    "postmessage",
    "queryselector",
    "requestanimationframe",
    "serviceworker",
    "storage/localstorage",
    "storage/sessionstorage",
    "svg",
    "svg/inline",
    "textarea/maxlength",
    "typed-arrays",
    "url/bloburls",
    "url/data-uri",
    "url/parser",
    "url/urlsearchparams",
    "webauthn/publickeycredential",
    "webrtc/datachannel",
    "webrtc/getusermedia",
    "webrtc/peerconnection",
    "websockets",
    "websockets/binary",
    "window/atob-btoa",
    "window/matchmedia",
    "workers/blobworkers",
    "workers/sharedworkers",
    "workers/transferables",
    "workers/webworkers"
  ]
}

Once all tests have been executed the html tag only has ' transferables datauri datauri-over32kb no-blobworkers' applied (with a single preceded white space) which are the feature tests that run async.

Expected behavior

All css classes should end up on html tag

@jnehlmeier
Copy link
Author

Looks like because I removed all options (since I thought only code required by feature checks would then be included in the final output) the final call to setClasses(classes) after calling the testRunner call was missing in the final JS output.

It basically looked like

  // Run each test
  testRunner();

  delete ModernizrProto.addTest;
  delete ModernizrProto.addAsyncTest;

even though the setClasses method itself was present in the final JS output.

Adding setClasses to the options array fixed that issue and the output now looks like

  // Run each test
  testRunner();

  // Remove the "no-js" class if it exists
  setClasses(classes);

  delete ModernizrProto.addTest;
  delete ModernizrProto.addAsyncTest;

So to be on the save spot I now include all options except html5shiv and html5printshiv.

Leaving the bug open since it might be unexpected behavior. Feel free to close it, if it is not.

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