mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 23:23:28 +00:00
Add Script get/set nonce
This commit is contained in:
@@ -977,6 +977,21 @@ pub const HTMLScriptElement = struct {
|
||||
return try parser.elementRemoveAttribute(parser.scriptToElt(self), "nomodule");
|
||||
}
|
||||
|
||||
pub fn get_nonce(self: *parser.Script) !?[]const u8 {
|
||||
return try parser.elementGetAttribute(
|
||||
parser.scriptToElt(self),
|
||||
"nonce",
|
||||
) orelse "";
|
||||
}
|
||||
|
||||
pub fn set_nonce(self: *parser.Script, v: []const u8) !void {
|
||||
try parser.elementSetAttribute(
|
||||
parser.scriptToElt(self),
|
||||
"nonce",
|
||||
v,
|
||||
);
|
||||
}
|
||||
|
||||
pub fn get_onload(self: *parser.Script, page: *Page) !?Env.Function {
|
||||
const state = page.getNodeState(@ptrCast(@alignCast(self))) orelse return null;
|
||||
return state.onload;
|
||||
|
||||
@@ -11,4 +11,8 @@
|
||||
|
||||
script.defer = true;
|
||||
testing.expectEqual(true, script.defer);
|
||||
|
||||
testing.expectEqual('', script.nonce);
|
||||
script.nonce = 'hello';
|
||||
testing.expectEqual('hello', script.nonce);
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user