Bug 1409976 - Add slotchange event

* Add support for `slotchange` event
* Signal `slotchange` when slot's assigned nodes changes

Tag #1375
This commit is contained in:
Matt A. Tobin 2020-04-17 07:35:48 -04:00 committed by Roy Tam
commit af22b5cba5
9 changed files with 174 additions and 160 deletions

View file

@ -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)
{