diff --git a/Userland/Libraries/LibWeb/DOM/MutationRecord.cpp b/Userland/Libraries/LibWeb/DOM/MutationRecord.cpp index 8a1af51767..0bb4aaf86b 100644 --- a/Userland/Libraries/LibWeb/DOM/MutationRecord.cpp +++ b/Userland/Libraries/LibWeb/DOM/MutationRecord.cpp @@ -12,12 +12,12 @@ namespace Web::DOM { -JS::NonnullGCPtr MutationRecord::create(JS::Realm& realm, FlyString const& type, Node const& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, DeprecatedString const& attribute_name, DeprecatedString const& attribute_namespace, DeprecatedString const& old_value) +JS::NonnullGCPtr MutationRecord::create(JS::Realm& realm, FlyString const& type, Node const& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, Optional const& attribute_name, Optional const& attribute_namespace, Optional const& old_value) { return realm.heap().allocate(realm, realm, type, target, added_nodes, removed_nodes, previous_sibling, next_sibling, attribute_name, attribute_namespace, old_value); } -MutationRecord::MutationRecord(JS::Realm& realm, FlyString const& type, Node const& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, DeprecatedString const& attribute_name, DeprecatedString const& attribute_namespace, DeprecatedString const& old_value) +MutationRecord::MutationRecord(JS::Realm& realm, FlyString const& type, Node const& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, Optional const& attribute_name, Optional const& attribute_namespace, Optional const& old_value) : PlatformObject(realm) , m_type(type) , m_target(JS::make_handle(target)) diff --git a/Userland/Libraries/LibWeb/DOM/MutationRecord.h b/Userland/Libraries/LibWeb/DOM/MutationRecord.h index 690103d3cf..6d89813aec 100644 --- a/Userland/Libraries/LibWeb/DOM/MutationRecord.h +++ b/Userland/Libraries/LibWeb/DOM/MutationRecord.h @@ -16,7 +16,7 @@ class MutationRecord : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(MutationRecord, Bindings::PlatformObject); public: - [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, FlyString const& type, Node const& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, DeprecatedString const& attribute_name, DeprecatedString const& attribute_namespace, DeprecatedString const& old_value); + [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&, FlyString const& type, Node const& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, Optional const& attribute_name, Optional const& attribute_namespace, Optional const& old_value); virtual ~MutationRecord() override; @@ -26,12 +26,12 @@ public: NodeList const* removed_nodes() const { return m_removed_nodes; } Node const* previous_sibling() const { return m_previous_sibling; } Node const* next_sibling() const { return m_next_sibling; } - DeprecatedString const& attribute_name() const { return m_attribute_name; } - DeprecatedString const& attribute_namespace() const { return m_attribute_namespace; } - DeprecatedString const& old_value() const { return m_old_value; } + Optional const& attribute_name() const { return m_attribute_name; } + Optional const& attribute_namespace() const { return m_attribute_namespace; } + Optional const& old_value() const { return m_old_value; } private: - MutationRecord(JS::Realm& realm, FlyString const& type, Node const& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, DeprecatedString const& attribute_name, DeprecatedString const& attribute_namespace, DeprecatedString const& old_value); + MutationRecord(JS::Realm& realm, FlyString const& type, Node const& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, Optional const& attribute_name, Optional const& attribute_namespace, Optional const& old_value); virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; @@ -42,9 +42,9 @@ private: JS::GCPtr m_removed_nodes; JS::GCPtr m_previous_sibling; JS::GCPtr m_next_sibling; - DeprecatedString m_attribute_name; - DeprecatedString m_attribute_namespace; - DeprecatedString m_old_value; + Optional m_attribute_name; + Optional m_attribute_namespace; + Optional m_old_value; }; } diff --git a/Userland/Libraries/LibWeb/DOM/MutationRecord.idl b/Userland/Libraries/LibWeb/DOM/MutationRecord.idl index 8e6ccb3054..0914177892 100644 --- a/Userland/Libraries/LibWeb/DOM/MutationRecord.idl +++ b/Userland/Libraries/LibWeb/DOM/MutationRecord.idl @@ -1,7 +1,7 @@ #import #import -[Exposed=Window, UseDeprecatedAKString] +[Exposed=Window] interface MutationRecord { readonly attribute DOMString type; diff --git a/Userland/Libraries/LibWeb/DOM/Node.cpp b/Userland/Libraries/LibWeb/DOM/Node.cpp index 38a0cf45ca..a63c41db8f 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.cpp +++ b/Userland/Libraries/LibWeb/DOM/Node.cpp @@ -1530,7 +1530,19 @@ void Node::queue_mutation_record(FlyString const& type, DeprecatedString attribu for (auto& interested_observer : interested_observers) { // 1. Let record be a new MutationRecord object with its type set to type, target set to target, attributeName set to name, attributeNamespace set to namespace, oldValue set to mappedOldValue, // addedNodes set to addedNodes, removedNodes set to removedNodes, previousSibling set to previousSibling, and nextSibling set to nextSibling. - auto record = MutationRecord::create(realm(), type, *this, added_nodes_list, removed_nodes_list, previous_sibling, next_sibling, attribute_name, attribute_namespace, /* mappedOldValue */ interested_observer.value); + Optional maybe_attribute_name; + if (!attribute_name.is_null()) + maybe_attribute_name = MUST(String::from_deprecated_string(attribute_name)); + + Optional maybe_attribute_namespace; + if (!attribute_namespace.is_null()) + maybe_attribute_namespace = MUST(String::from_deprecated_string(attribute_namespace)); + + Optional maybe_interested_observer; + if (!interested_observer.value.is_null()) + maybe_interested_observer = MUST(String::from_deprecated_string(interested_observer.value)); + + auto record = MutationRecord::create(realm(), type, *this, added_nodes_list, removed_nodes_list, previous_sibling, next_sibling, maybe_attribute_name, maybe_attribute_namespace, /* mappedOldValue */ maybe_interested_observer); // 2. Enqueue record to observer’s record queue. interested_observer.key->enqueue_record({}, move(record));