klass icon indicating copy to clipboard operation
klass copied to clipboard

Leaking global 'supr' symbol when calling supr using methods without proper this context

Open dwt opened this issue 9 years ago • 0 comments

Hi there,

we just noticed that klass will leak a global 'supr' value when you call a supr-using method without a this-context.

What happens, is that the wrapper will assign this.supr to the correct super method - but of course this is now the windows (or global) object.

I'm actually not entirely sure how this should be fixed, what we came up with was to either raise if this === window or just remove this.supr after the super call has taken place if the supr key wasn't not the object before the call.

Interestingly this.supr(...) actually works, even when the wrong this context is used for a method. (Which is actually quite surprising)

Asserting that this cannot be the global object supr() using code seems to make most sense here.

What do you think?

dwt avatar Aug 15 '16 09:08 dwt