File tree Expand file tree Collapse file tree 3 files changed +32
-1
lines changed Expand file tree Collapse file tree 3 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -86,7 +86,19 @@ pub const Node = struct {
8686 },
8787 .document_type = > .{ .DocumentType = @as (* parser .DocumentType , @ptrCast (node )) },
8888 .attribute = > .{ .Attr = @as (* parser .Attribute , @ptrCast (node )) },
89- .document_fragment = > .{ .DocumentFragment = @as (* parser .DocumentFragment , @ptrCast (node )) },
89+ .document_fragment = > blk : {
90+ const df : * parser.DocumentFragment = @ptrCast (node );
91+ if (parser .documentFragmentGetHost (df )) | host | {
92+ // If the DocumentFragment has a "host", then it's 100%
93+ // acting as the root of the ShadowDOM. And I *think*, in
94+ // those cases, if we end up with that DocumentFragment, we
95+ // should actually return the host. For example, if there's
96+ // A MutationObservation on the DocumentFragment, it's the
97+ // Host which we should treat as the target. I think.
98+ break :blk toInterface (host );
99+ }
100+ break :blk .{ .DocumentFragment = df };
101+ },
90102 else = > @panic ("node type not handled" ), // TODO
91103 };
92104 }
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 : bool ) ! void {
988+ if (v ) {
989+ return try parser .elementSetAttribute (parser .scriptToElt (self ), "nonce" , "" );
990+ }
991+
992+ return try parser .elementRemoveAttribute (parser .scriptToElt (self ), "nonce" );
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