mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 17:28:30 +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:
@@ -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