dom: implement ProcessingIntruction.target

This commit is contained in:
Pierre Tachoire
2023-12-07 17:02:14 +01:00
parent d13da6ffab
commit 9b9d927f38
2 changed files with 6 additions and 2 deletions

View File

@@ -258,7 +258,8 @@ pub fn testExecFn(
try checkCases(js_env, &createComment);
var createProcessingInstruction = [_]Case{
.{ .src = "document.createProcessingInstruction('foo', 'bar')", .ex = "[object ProcessingInstruction]" },
.{ .src = "let pi = document.createProcessingInstruction('foo', 'bar')", .ex = "undefined" },
.{ .src = "pi.target", .ex = "foo" },
};
try checkCases(js_env, &createProcessingInstruction);

View File

@@ -10,5 +10,8 @@ pub const ProcessingInstruction = struct {
pub const prototype = *CharacterData;
pub const mem_guarantied = true;
// TODO implement get_target
pub fn get_target(self: *parser.ProcessingInstruction) ![]const u8 {
// libdom stores the ProcessingInstruction target in the node's name.
return try parser.nodeName(@as(*parser.Node, @ptrCast(self)));
}
};