mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 18:47:44 +00:00
LibWeb: Add Document.createProcessingInstruction()
These nodes don't really do anything interesting yet, but let's allow creating them. :^)
This commit is contained in:
parent
bf759ce5e3
commit
8b0ace6289
3 changed files with 17 additions and 0 deletions
|
@ -29,6 +29,7 @@
|
||||||
#include <LibWeb/DOM/Event.h>
|
#include <LibWeb/DOM/Event.h>
|
||||||
#include <LibWeb/DOM/HTMLCollection.h>
|
#include <LibWeb/DOM/HTMLCollection.h>
|
||||||
#include <LibWeb/DOM/NodeIterator.h>
|
#include <LibWeb/DOM/NodeIterator.h>
|
||||||
|
#include <LibWeb/DOM/ProcessingInstruction.h>
|
||||||
#include <LibWeb/DOM/Range.h>
|
#include <LibWeb/DOM/Range.h>
|
||||||
#include <LibWeb/DOM/ShadowRoot.h>
|
#include <LibWeb/DOM/ShadowRoot.h>
|
||||||
#include <LibWeb/DOM/Text.h>
|
#include <LibWeb/DOM/Text.h>
|
||||||
|
@ -1233,6 +1234,17 @@ JS::NonnullGCPtr<Comment> Document::create_comment(DeprecatedString const& data)
|
||||||
return *heap().allocate<Comment>(realm(), *this, data);
|
return *heap().allocate<Comment>(realm(), *this, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://dom.spec.whatwg.org/#dom-document-createprocessinginstruction
|
||||||
|
WebIDL::ExceptionOr<JS::NonnullGCPtr<ProcessingInstruction>> Document::create_processing_instruction(DeprecatedString const& target, DeprecatedString const& data)
|
||||||
|
{
|
||||||
|
// FIXME: 1. If target does not match the Name production, then throw an "InvalidCharacterError" DOMException.
|
||||||
|
|
||||||
|
// FIXME: 2. If data contains the string "?>", then throw an "InvalidCharacterError" DOMException.
|
||||||
|
|
||||||
|
// 3. Return a new ProcessingInstruction node, with target set to target, data set to data, and node document set to this.
|
||||||
|
return JS::NonnullGCPtr { *heap().allocate<ProcessingInstruction>(realm(), *this, data, target) };
|
||||||
|
}
|
||||||
|
|
||||||
JS::NonnullGCPtr<Range> Document::create_range()
|
JS::NonnullGCPtr<Range> Document::create_range()
|
||||||
{
|
{
|
||||||
return Range::create(*this);
|
return Range::create(*this);
|
||||||
|
|
|
@ -227,6 +227,8 @@ public:
|
||||||
JS::NonnullGCPtr<DocumentFragment> create_document_fragment();
|
JS::NonnullGCPtr<DocumentFragment> create_document_fragment();
|
||||||
JS::NonnullGCPtr<Text> create_text_node(DeprecatedString const& data);
|
JS::NonnullGCPtr<Text> create_text_node(DeprecatedString const& data);
|
||||||
JS::NonnullGCPtr<Comment> create_comment(DeprecatedString const& data);
|
JS::NonnullGCPtr<Comment> create_comment(DeprecatedString const& data);
|
||||||
|
WebIDL::ExceptionOr<JS::NonnullGCPtr<ProcessingInstruction>> create_processing_instruction(DeprecatedString const& target, DeprecatedString const& data);
|
||||||
|
|
||||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<Event>> create_event(DeprecatedString const& interface);
|
WebIDL::ExceptionOr<JS::NonnullGCPtr<Event>> create_event(DeprecatedString const& interface);
|
||||||
JS::NonnullGCPtr<Range> create_range();
|
JS::NonnullGCPtr<Range> create_range();
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#import <DOM/NodeIterator.idl>
|
#import <DOM/NodeIterator.idl>
|
||||||
#import <DOM/NodeList.idl>
|
#import <DOM/NodeList.idl>
|
||||||
#import <DOM/ParentNode.idl>
|
#import <DOM/ParentNode.idl>
|
||||||
|
#import <DOM/ProcessingInstruction.idl>
|
||||||
#import <DOM/Range.idl>
|
#import <DOM/Range.idl>
|
||||||
#import <DOM/Text.idl>
|
#import <DOM/Text.idl>
|
||||||
#import <DOM/TreeWalker.idl>
|
#import <DOM/TreeWalker.idl>
|
||||||
|
@ -78,6 +79,8 @@ interface Document : Node {
|
||||||
DocumentFragment createDocumentFragment();
|
DocumentFragment createDocumentFragment();
|
||||||
Text createTextNode(DOMString data);
|
Text createTextNode(DOMString data);
|
||||||
Comment createComment(DOMString data);
|
Comment createComment(DOMString data);
|
||||||
|
[NewObject] ProcessingInstruction createProcessingInstruction(DOMString target, DOMString data);
|
||||||
|
|
||||||
Range createRange();
|
Range createRange();
|
||||||
Event createEvent(DOMString interface);
|
Event createEvent(DOMString interface);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue