mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 15:13:28 +00:00
dom: implement document fragment constructor
This commit is contained in:
@@ -20,20 +20,39 @@ const std = @import("std");
|
|||||||
|
|
||||||
const parser = @import("../netsurf.zig");
|
const parser = @import("../netsurf.zig");
|
||||||
|
|
||||||
|
const jsruntime = @import("jsruntime");
|
||||||
|
const Case = jsruntime.test_utils.Case;
|
||||||
|
const checkCases = jsruntime.test_utils.checkCases;
|
||||||
|
|
||||||
const Node = @import("node.zig").Node;
|
const Node = @import("node.zig").Node;
|
||||||
|
|
||||||
|
const UserContext = @import("../user_context.zig").UserContext;
|
||||||
|
|
||||||
// WEB IDL https://dom.spec.whatwg.org/#documentfragment
|
// WEB IDL https://dom.spec.whatwg.org/#documentfragment
|
||||||
pub const DocumentFragment = struct {
|
pub const DocumentFragment = struct {
|
||||||
pub const Self = parser.DocumentFragment;
|
pub const Self = parser.DocumentFragment;
|
||||||
pub const prototype = *Node;
|
pub const prototype = *Node;
|
||||||
pub const mem_guarantied = true;
|
pub const mem_guarantied = true;
|
||||||
|
|
||||||
// TODO add constructor, but I need to associate the new DocumentFragment
|
pub fn constructor(userctx: UserContext) !*parser.DocumentFragment {
|
||||||
// with the current document global object...
|
if (userctx.document == null) return parser.DOMError.NotSupported;
|
||||||
// > The new DocumentFragment() constructor steps are to set this’s node
|
|
||||||
// > document to current global object’s associated Document.
|
return parser.documentCreateDocumentFragment(
|
||||||
// https://dom.spec.whatwg.org/#dom-documentfragment-documentfragment
|
parser.documentHTMLToDocument(userctx.document.?),
|
||||||
pub fn constructor() !*parser.DocumentFragment {
|
);
|
||||||
return error.NotImplemented;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Tests
|
||||||
|
// -----
|
||||||
|
|
||||||
|
pub fn testExecFn(
|
||||||
|
_: std.mem.Allocator,
|
||||||
|
js_env: *jsruntime.Env,
|
||||||
|
) anyerror!void {
|
||||||
|
var constructor = [_]Case{
|
||||||
|
.{ .src = "const dc = new DocumentFragment()", .ex = "undefined" },
|
||||||
|
.{ .src = "dc.constructor.name", .ex = "DocumentFragment" },
|
||||||
|
};
|
||||||
|
try checkCases(js_env, &constructor);
|
||||||
|
}
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ const AttrTestExecFn = @import("dom/attribute.zig").testExecFn;
|
|||||||
const EventTargetTestExecFn = @import("dom/event_target.zig").testExecFn;
|
const EventTargetTestExecFn = @import("dom/event_target.zig").testExecFn;
|
||||||
const ProcessingInstructionTestExecFn = @import("dom/processing_instruction.zig").testExecFn;
|
const ProcessingInstructionTestExecFn = @import("dom/processing_instruction.zig").testExecFn;
|
||||||
const CommentTestExecFn = @import("dom/comment.zig").testExecFn;
|
const CommentTestExecFn = @import("dom/comment.zig").testExecFn;
|
||||||
|
const DocumentFragmentTestExecFn = @import("dom/document_fragment.zig").testExecFn;
|
||||||
const EventTestExecFn = @import("events/event.zig").testExecFn;
|
const EventTestExecFn = @import("events/event.zig").testExecFn;
|
||||||
const XHRTestExecFn = xhr.testExecFn;
|
const XHRTestExecFn = xhr.testExecFn;
|
||||||
const ProgressEventTestExecFn = @import("xhr/progress_event.zig").testExecFn;
|
const ProgressEventTestExecFn = @import("xhr/progress_event.zig").testExecFn;
|
||||||
@@ -116,6 +117,7 @@ fn testsAllExecFn(
|
|||||||
NodeListTestExecFn,
|
NodeListTestExecFn,
|
||||||
AttrTestExecFn,
|
AttrTestExecFn,
|
||||||
CommentTestExecFn,
|
CommentTestExecFn,
|
||||||
|
DocumentFragmentTestExecFn,
|
||||||
EventTargetTestExecFn,
|
EventTargetTestExecFn,
|
||||||
EventTestExecFn,
|
EventTestExecFn,
|
||||||
XHRTestExecFn,
|
XHRTestExecFn,
|
||||||
|
|||||||
Reference in New Issue
Block a user