mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 15:13:28 +00:00
dom: document.documentURI and document.URL
This commit is contained in:
@@ -34,6 +34,15 @@ pub const Document = struct {
|
|||||||
return Element.toInterface(e);
|
return Element.toInterface(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_documentURI(self: *parser.Document) []const u8 {
|
||||||
|
return parser.documentGetDocumentURI(self);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO should be get_URL but in this case, document.URL is indefined.
|
||||||
|
pub fn get_url(self: *parser.Document) []const u8 {
|
||||||
|
return get_documentURI(self);
|
||||||
|
}
|
||||||
|
|
||||||
// TODO implement contentType
|
// TODO implement contentType
|
||||||
pub fn get_contentType(self: *parser.Document) []const u8 {
|
pub fn get_contentType(self: *parser.Document) []const u8 {
|
||||||
_ = self;
|
_ = self;
|
||||||
@@ -168,6 +177,13 @@ pub fn testExecFn(
|
|||||||
};
|
};
|
||||||
try checkCases(js_env, &getContentType);
|
try checkCases(js_env, &getContentType);
|
||||||
|
|
||||||
|
var getDocumentURI = [_]Case{
|
||||||
|
.{ .src = "document.documentURI", .ex = "about:blank" },
|
||||||
|
// TODO should be document.URL
|
||||||
|
.{ .src = "document.url", .ex = "about:blank" },
|
||||||
|
};
|
||||||
|
try checkCases(js_env, &getDocumentURI);
|
||||||
|
|
||||||
const tags = comptime parser.Tag.all();
|
const tags = comptime parser.Tag.all();
|
||||||
comptime var createElements: [(tags.len) * 2]Case = undefined;
|
comptime var createElements: [(tags.len) * 2]Case = undefined;
|
||||||
inline for (tags, 0..) |tag, i| {
|
inline for (tags, 0..) |tag, i| {
|
||||||
|
|||||||
@@ -794,6 +794,12 @@ pub inline fn documentGetDocumentElement(doc: *Document) *Element {
|
|||||||
return elem.?;
|
return elem.?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub inline fn documentGetDocumentURI(doc: *Document) []const u8 {
|
||||||
|
var s: ?*String = undefined;
|
||||||
|
_ = documentVtable(doc).dom_document_get_uri.?(doc, &s);
|
||||||
|
return stringToData(s.?);
|
||||||
|
}
|
||||||
|
|
||||||
pub inline fn documentCreateElement(doc: *Document, tag_name: []const u8) *Element {
|
pub inline fn documentCreateElement(doc: *Document, tag_name: []const u8) *Element {
|
||||||
var elem: ?*Element = undefined;
|
var elem: ?*Element = undefined;
|
||||||
_ = documentVtable(doc).dom_document_create_element.?(doc, stringFromData(tag_name), &elem);
|
_ = documentVtable(doc).dom_document_create_element.?(doc, stringFromData(tag_name), &elem);
|
||||||
|
|||||||
Reference in New Issue
Block a user