mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-02 01:08:48 +00:00
LibWeb: Implement <template> parsing
Note that there is currently no way to display them as we can't currently clone nodes. Adds special case for templates for dumping to console. Doesn't add it to the DOM inspector as I'm not sure how to do it.
This commit is contained in:
parent
f48feae0b2
commit
7902d215b3
Notes:
sideshowbarker
2024-07-19 03:23:09 +09:00
Author: https://github.com/Lubrsi
Commit: 7902d215b3
Pull-request: https://github.com/SerenityOS/serenity/pull/3224
Reviewed-by: https://github.com/awesomekling
14 changed files with 174 additions and 28 deletions
27
Libraries/LibWeb/Tests/HTML/HTMLTemplateElement.js
Normal file
27
Libraries/LibWeb/Tests/HTML/HTMLTemplateElement.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
loadPage("file:///home/anon/web-tests/Pages/Template.html");
|
||||
|
||||
afterInitialPageLoad(() => {
|
||||
test("Basic functionality", () => {
|
||||
const template = document.getElementById("template");
|
||||
expect(template).not.toBeNull();
|
||||
|
||||
// The contents of a template element are not children of the actual element.
|
||||
// The document fragment is not a child of the element either.
|
||||
expect(template.firstChild).toBeNull();
|
||||
|
||||
// FIXME: Add this in once DocumentFragment's constructor is implemented.
|
||||
//expect(template.content).toBeInstanceOf(DocumentFragment);
|
||||
expect(template.content.nodeName).toBe("#document-fragment");
|
||||
|
||||
const templateDiv = template.content.getElementById("templatediv");
|
||||
expect(templateDiv.nodeName).toBe("div");
|
||||
expect(templateDiv.textContent).toBe("Hello template!");
|
||||
});
|
||||
|
||||
test("Templates are inert (e.g. scripts won't run)", () => {
|
||||
// The page has a template element with a script element in it.
|
||||
// Templates are inert, for example, they won't run scripts.
|
||||
// That script will set "templateScriptRan" to true if it ran.
|
||||
expect(window.templateScriptRan).toBeUndefined();
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue