mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-26 06:18:59 +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
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue