Google 網路論壇不再支援新的 Usenet 貼文或訂閱項目,但過往內容仍可供查看。

Equivalent of "super" in XBL?

瀏覽次數:25 次
跳到第一則未讀訊息

Greg Allen

未讀,
2010年3月30日 晚上10:10:502010/3/30
收件者:
Is there an equivalent of the Java "super" in XBL?

I have two bindings, "a" and "b". Binding "b" extends "a". Both define
the method "method".

I'd like to be able to call a.method() from b.method(), after b.method has
done some other stuff.

Can this be done?

Thanks,

-- Greg


Boris Zbarsky

未讀,
2010年3月30日 晚上10:47:582010/3/30
收件者:

I _think_ that this.__proto__.__proto__.method should be the right thing
if you know b is the most-derived binding....

In the general case, though, you can't do it in xbl1. Not sure about xbl2.

-Boris

Sean Hogan

未讀,
2010年3月30日 晚上11:50:522010/3/30
收件者:Greg Allen、dev-te...@lists.mozilla.org

In XBL2 there is the baseBinding property on binding instances.
See http://www.w3.org/TR/xbl/#basebinding


Andrew Sutherland

未讀,
2010年4月1日 下午2:03:382010/4/1
收件者:
On 03/30/2010 07:47 PM, Boris Zbarsky wrote:
> I _think_ that this.__proto__.__proto__.method should be the right thing
> if you know b is the most-derived binding....

Note that you would probably want to use 'call' (or 'apply') to avoid
'this' being the prototype instead of the actual instance:

this.__proto__.__proto__.method.call(this, ...);

or

this.__proto__.__proto__.method.apply(this, arguments);

Andrew

0 則新訊息