summaryrefslogtreecommitdiffstats
path: root/dom/html
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2020-04-17 07:35:48 -0400
committerMatt A. Tobin <email@mattatobin.com>2020-04-17 07:35:48 -0400
commit3508e79b1fe7fc928eed2f3c7bf2d628c53fbf17 (patch)
treec793eb598816afa68a560c4224b06ca15b8ad55c /dom/html
parentf164962a3dc53f4823dfff6c77e7972c72d4c61f (diff)
downloadUXP-3508e79b1fe7fc928eed2f3c7bf2d628c53fbf17.tar
UXP-3508e79b1fe7fc928eed2f3c7bf2d628c53fbf17.tar.gz
UXP-3508e79b1fe7fc928eed2f3c7bf2d628c53fbf17.tar.lz
UXP-3508e79b1fe7fc928eed2f3c7bf2d628c53fbf17.tar.xz
UXP-3508e79b1fe7fc928eed2f3c7bf2d628c53fbf17.zip
Bug 1409976 - Add `slotchange` event
* Add support for `slotchange` event * Signal `slotchange` when slot's assigned nodes changes Tag #1375
Diffstat (limited to 'dom/html')
-rw-r--r--dom/html/HTMLSlotElement.cpp21
-rw-r--r--dom/html/HTMLSlotElement.h3
2 files changed, 24 insertions, 0 deletions
diff --git a/dom/html/HTMLSlotElement.cpp b/dom/html/HTMLSlotElement.cpp
index b13729a09..18b8ef87b 100644
--- a/dom/html/HTMLSlotElement.cpp
+++ b/dom/html/HTMLSlotElement.cpp
@@ -4,6 +4,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+#include "mozilla/dom/DocGroup.h"
#include "mozilla/dom/HTMLSlotElement.h"
#include "mozilla/dom/HTMLSlotElementBinding.h"
#include "mozilla/dom/HTMLUnknownElement.h"
@@ -204,6 +205,26 @@ HTMLSlotElement::ClearAssignedNodes()
mAssignedNodes.Clear();
}
+void
+HTMLSlotElement::EnqueueSlotChangeEvent() const
+{
+ DocGroup* docGroup = OwnerDoc()->GetDocGroup();
+ if (!docGroup) {
+ return;
+ }
+
+ docGroup->SignalSlotChange(this);
+}
+
+void
+HTMLSlotElement::FireSlotChangeEvent()
+{
+ nsContentUtils::DispatchTrustedEvent(OwnerDoc(),
+ static_cast<nsIContent*>(this),
+ NS_LITERAL_STRING("slotchange"), true,
+ false);
+}
+
JSObject*
HTMLSlotElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
diff --git a/dom/html/HTMLSlotElement.h b/dom/html/HTMLSlotElement.h
index 4f8546200..0494a654e 100644
--- a/dom/html/HTMLSlotElement.h
+++ b/dom/html/HTMLSlotElement.h
@@ -62,6 +62,9 @@ public:
void RemoveAssignedNode(nsINode* aNode);
void ClearAssignedNodes();
+ void EnqueueSlotChangeEvent() const;
+ void FireSlotChangeEvent();
+
protected:
virtual ~HTMLSlotElement();
virtual JSObject*