link stylesheet with nonce fails CSP when media="none"

When I add media="none" onload="if(media!='all')media='all'" to this link element, it fails the CSP (Content Security Policy).

<link nonce="some-nonce" rel="stylesheet" href="/stylesheets/style.css" media="none" onload="if(media!='all')media='all'">

Whereas this works:

<link nonce="some-nonce" rel="stylesheet" href="/stylesheets/style.css">

Any idea of how to make the nonce work for the first version?