dom: implement document.createProcessingInstruction

This commit is contained in:
Pierre Tachoire
2023-12-07 16:48:02 +01:00
parent 24ec5f554d
commit d13da6ffab
5 changed files with 41 additions and 0 deletions

View File

@@ -818,6 +818,9 @@ pub fn textSplitText(text: *Text, offset: u32) !*Text {
// Comment
pub const Comment = c.dom_comment;
// ProcessingInstruction
pub const ProcessingInstruction = c.dom_processing_instruction;
// Attribute
pub const Attribute = c.dom_attr;
@@ -1161,6 +1164,18 @@ pub inline fn documentCreateComment(doc: *Document, s: []const u8) !*Comment {
return com.?;
}
pub inline fn documentCreateProcessingInstruction(doc: *Document, target: []const u8, data: []const u8) !*ProcessingInstruction {
var pi: ?*ProcessingInstruction = undefined;
const err = documentVtable(doc).dom_document_create_processing_instruction.?(
doc,
try strFromData(target),
try strFromData(data),
&pi,
);
try DOMErr(err);
return pi.?;
}
// DocumentHTML
pub const DocumentHTML = c.dom_html_document;