mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-28 10:37:17 +02: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:
Notes:
sideshowbarker
2024-07-19 03:23:09 +09:00
Author: https://github.com/Lubrsi Commit: https://github.com/SerenityOS/serenity/commit/7902d215b39 Pull-request: https://github.com/SerenityOS/serenity/pull/3224 Reviewed-by: https://github.com/awesomekling
@@ -24,6 +24,7 @@
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/HTML/HTMLTemplateElement.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
@@ -31,10 +32,30 @@ namespace Web::HTML {
|
||||
HTMLTemplateElement::HTMLTemplateElement(DOM::Document& document, const FlyString& tag_name)
|
||||
: HTMLElement(document, tag_name)
|
||||
{
|
||||
m_content = adopt(*new DOM::DocumentFragment(appropriate_template_contents_owner_document(document)));
|
||||
m_content->set_host(*this);
|
||||
}
|
||||
|
||||
HTMLTemplateElement::~HTMLTemplateElement()
|
||||
{
|
||||
}
|
||||
|
||||
DOM::Document& HTMLTemplateElement::appropriate_template_contents_owner_document(DOM::Document& document)
|
||||
{
|
||||
if (!document.created_for_appropriate_template_contents()) {
|
||||
if (!document.associated_inert_template_document()) {
|
||||
DOM::Document new_document;
|
||||
new_document.set_created_for_appropriate_template_contents(true);
|
||||
|
||||
// FIXME: If doc is an HTML document, mark new doc as an HTML document also.
|
||||
|
||||
document.set_associated_inert_template_document(new_document);
|
||||
}
|
||||
|
||||
return *document.associated_inert_template_document();
|
||||
}
|
||||
|
||||
return document;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user