File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -977,6 +977,21 @@ pub const HTMLScriptElement = struct {
977977 return try parser .elementRemoveAttribute (parser .scriptToElt (self ), "nomodule" );
978978 }
979979
980+ pub fn get_nonce (self : * parser.Script ) ! ? []const u8 {
981+ return try parser .elementGetAttribute (
982+ parser .scriptToElt (self ),
983+ "nonce" ,
984+ ) orelse "" ;
985+ }
986+
987+ pub fn set_nonce (self : * parser.Script , v : []const u8 ) ! void {
988+ try parser .elementSetAttribute (
989+ parser .scriptToElt (self ),
990+ "nonce" ,
991+ v ,
992+ );
993+ }
994+
980995 pub fn get_onload (self : * parser.Script , page : * Page ) ! ? Env.Function {
981996 const state = page .getNodeState (@ptrCast (@alignCast (self ))) orelse return null ;
982997 return state .onload ;
Original file line number Diff line number Diff line change 1111
1212 script . defer = true ;
1313 testing . expectEqual ( true , script . defer ) ;
14+
15+ testing . expectEqual ( '' , script . nonce ) ;
16+ script . nonce = 'hello' ;
17+ testing . expectEqual ( 'hello' , script . nonce ) ;
1418</ script >
You can’t perform that action at this time.
0 commit comments