File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change 1+ {
2+ "[javascript]" : {
3+ "editor.defaultFormatter" : " biomejs.biome"
4+ }
5+ }
Original file line number Diff line number Diff line change @@ -38,6 +38,8 @@ export function createOc(oc) {
3838 let renderedComponents = oc . renderedComponents ;
3939 let dataRenderedAttribute = "data-rendered" ;
4040 let dataRenderingAttribute = "data-rendering" ;
41+ let nonce = $document . currentScript ?. nonce ;
42+
4143 let logError = ( msg ) => console . log ( msg ) ;
4244 let logInfo = ( msg ) => ocConf . debug && console . log ( msg ) ;
4345 let handleFetchResponse = ( response ) => {
@@ -124,6 +126,9 @@ export function createOc(oc) {
124126 for ( let attribute of Array . from ( script . attributes ) ) {
125127 newScript . setAttribute ( attribute . name , attribute . value ) ;
126128 }
129+ if ( nonce ) {
130+ newScript . setAttribute ( "nonce" , nonce ) ;
131+ }
127132 script . parentNode ?. replaceChild ( newScript , script ) ;
128133 }
129134 } ;
@@ -140,6 +145,9 @@ export function createOc(oc) {
140145 oc . addStylesToHead = ( styles ) => {
141146 let style = $document . createElement ( "style" ) ;
142147 style . textContent = styles ;
148+ if ( nonce ) {
149+ style . setAttribute ( "nonce" , nonce ) ;
150+ }
143151 $document . head . appendChild ( style ) ;
144152 } ;
145153
You can’t perform that action at this time.
0 commit comments