-
Notifications
You must be signed in to change notification settings - Fork 288
Create HTMLElement instead of pure Element #919
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
I think you could stop it from crashing by calling |
|
So as you suggested, as used |
|
I pushed more changed to remove But i have so still in progress... |
e75ba67 to
ce83e68
Compare
|
@karlseguin WPT tests are passing now. |
|
Hum, Maybe I should keep |
ce83e68 to
39fc5a7
Compare
|
ok here is a cleaner version |
src/browser/netsurf.zig
Outdated
| return doc_html; | ||
| } | ||
|
|
||
| pub inline fn documentCreateHTMLElement(doc: *Document, tag_name: []const u8) !*Element { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know everything in netsurf.zig is inlined, but Andrew's not a fan:
src/browser/netsurf.zig
Outdated
| return doc_html; | ||
| } | ||
|
|
||
| pub inline fn documentCreateHTMLElement(doc: *Document, tag_name: []const u8) !*Element { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to keep the originals? If our document is always an html document, then it will always create an HTMLElement. Only reason I can see to keep both is if we think we'll have a non-html document??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can create non-html document from scratch in JS and then add elements to them.
If I try to use only HTML element creation, WPT test is crashing on https://github.com/lightpanda-io/wpt/blob/main/html/dom/documents/dom-tree-accessors/document.title-09.html.
It's b/c the document isn't an HTML one.
So depending the document, we want to create HTMLElement or Element...
I could maybe detect the document's type and use the best function...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid I can't find a way to detect if a document is an HTML one...
The constructor doesn't set any base doc attribute with a specific value.
https://github.com/lightpanda-io/libdom/blob/master/src/html/html_document.c#L93-L116
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok I did with lightpanda-io/libdom#32
|
LGTM |
For XML documents, the documentElement could be another element than HTMLElement. So we don't want to pass to through the toInterface.
3ec792c to
0fee2bb
Compare
Our
toInterfaceexpect the given Element is always an HTMLElement.So I think it's better to create always HTMLElement.No b/c we could want to create a non-HTML tag, eg. svgBut I would also like to detect if an Element is really an HTMLElement to avoid crash ondone usingtoInterface, but I can't figure out one correct solution..._dom_element_get_tag_name✔️depends on lightpanda-io/libdom#32