# HG changeset patch # User Boris Zbarsky # Date 1520483894 18000 # Node ID e101b0c833ffab505fe916afac194c01f0af37dd # Parent 7ed8a3893667c0b52a2f7aeaefeb0faecaa81617 Bug 1444004. Implement Event.prototype.srcElement as an alias for .target, nightly-only. r=smaug MozReview-Commit-ID: JhKdc07CVsL diff --git a/dom/events/Event.cpp b/dom/events/Event.cpp --- a/dom/events/Event.cpp +++ b/dom/events/Event.cpp @@ -239,16 +239,27 @@ Event::GetTarget() const NS_IMETHODIMP Event::GetTarget(nsIDOMEventTarget** aTarget) { NS_IF_ADDREF(*aTarget = GetTarget()); return NS_OK; } +bool +Event::IsSrcElementEnabled(JSContext* /* unused */, JSObject* /* unused */) +{ + // Not a pref, because that's a pain on workers. +#ifdef NIGHTLY_BUILD + return true; +#else + return false; +#endif +} + EventTarget* Event::GetCurrentTarget() const { return mEvent->GetCurrentDOMEventTarget(); } void Event::ComposedPath(nsTArray>& aPath) diff --git a/dom/events/Event.h b/dom/events/Event.h --- a/dom/events/Event.h +++ b/dom/events/Event.h @@ -151,16 +151,17 @@ public: const nsAString& aType, const EventInit& aParam, ErrorResult& aRv); // Implemented as xpidl method // void GetType(nsString& aRetval) {} EventTarget* GetTarget() const; + static bool IsSrcElementEnabled(JSContext* /* unused */, JSObject* /* unused */); EventTarget* GetCurrentTarget() const; void ComposedPath(nsTArray>& aPath); uint16_t EventPhase() const; // xpidl implementation // void StopPropagation(); diff --git a/dom/webidl/Event.webidl b/dom/webidl/Event.webidl --- a/dom/webidl/Event.webidl +++ b/dom/webidl/Event.webidl @@ -12,16 +12,18 @@ [Constructor(DOMString type, optional EventInit eventInitDict), Exposed=(Window,Worker,System), ProbablyShortLivingWrapper] interface Event { [Pure] readonly attribute DOMString type; [Pure] readonly attribute EventTarget? target; + [Pure, BinaryName="target", Func="Event::IsSrcElementEnabled"] + readonly attribute EventTarget? srcElement; [Pure] readonly attribute EventTarget? currentTarget; sequence composedPath(); const unsigned short NONE = 0; const unsigned short CAPTURING_PHASE = 1; const unsigned short AT_TARGET = 2;