CustomEvent.cpp 712 B

123456789101112131415161718192021222324252627282930
  1. /*
  2. * Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibWeb/DOM/CustomEvent.h>
  7. namespace Web::DOM {
  8. void CustomEvent::visit_edges(JS::Cell::Visitor& visitor)
  9. {
  10. visitor.visit(m_detail);
  11. }
  12. // https://dom.spec.whatwg.org/#dom-customevent-initcustomevent
  13. void CustomEvent::init_custom_event(String const& type, bool bubbles, bool cancelable, JS::Value detail)
  14. {
  15. // 1. If this’s dispatch flag is set, then return.
  16. if (dispatched())
  17. return;
  18. // 2. Initialize this with type, bubbles, and cancelable.
  19. initialize(type, bubbles, cancelable);
  20. // 3. Set this’s detail attribute to detail.
  21. m_detail = detail;
  22. }
  23. }